Skip to content

Instantly share code, notes, and snippets.

@richhickey
Created December 2, 2009 12:24
Show Gist options
  • Save richhickey/247172 to your computer and use it in GitHub Desktop.
Save richhickey/247172 to your computer and use it in GitHub Desktop.
;variants of the code from point #2 of:
; http://www.tbray.org/ongoing/When/200x/2009/12/01/Clojure-Theses
;original
(apply merge-with +
(pmap count-lines
(partition-all *batch-size*
(line-seq (reader filename)))))
;pipelined style
(->> (line-seq (reader filename))
(partition-all *batch-size*)
(pmap count-lines)
(apply merge-with +))
;step-wise, with labeled interim results
(let [lines (line-seq (reader filename))
processed-data (pmap count-lines
(partition-all *batch-size* lines))]
(apply merge-with + processed-data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment