From: Ken A. <kan...@bb...> - 2004-06-23 23:10:35
|
I wrote this piece of code today and it struck me: (define (readCountryData) (sort (remove-duplicates (readingTabData (File. "../dafif/Dafift/AppC/appc_cc_icao.txt") (lambda (country country_name icao_rgn usage) (list country country_name)))) (comparator string<? car))) (define (readingTabData file f) (map* (lambda (r) (apply f (vector->list (.split r "\t")))) (BufferedReader. (FileReader. file)))) Now, this code can be improved in a lot of ways, but it did what i wanted - grind over a tab separated file, extract the fields i wanted, and sort the result. It also abstracted out readinging from a tab separated file so it can be resused. While you might argue that i should have produced an iterator to be Java compatible, to do it in Java, you'd need an interface with methods call and apply, and each of the 4 loops would require at least 50% more lines of code. |