How about this for a start? (reduce (fn [m line] (if (empty? line) m (if-let [size (get (re-matches #"([0-9]+) byte\(null\)each:" line) 1)] (merge m {:size size}) (if-let [file (get (re-matches #".*(\.[0-9a-zA-Z]+)" line) 1)] (let [size (:size m)] (merge-with (fn [[cnt size] _] [(inc cnt) size]) m {file [0 size]})) (throw (IllegalStateException. (str "not sure what to do with \"" line "\""))))))) {} (line-seq (reader "/home/windfall/hacking/sharpening-of-the-saw/test-data/test1.in")))
For your sample data, the above produces: {".sta" [1 "102"], ".UWL" [2 "14171"], ".ini" [1 "71"], :size "102"} You'll probably need to drop the :size key from the result map, convert strings to integers, multiply counts by sizes etc. -- I leave that to you. All best, Michał -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en