-
-
Save mdemare/248515 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;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 +)) | |
;comp style | |
((comp | |
(partial apply merge-with +)) | |
(partial pmap count-lines) | |
(partial partition-all *batch-size*) | |
line-seq | |
reader) | |
filename) | |
;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