Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Reducing over large files
(defn line-reducible
"Returns a reducible collection over stream of lines from a BufferedReader"
[^BufferedReader r]
(reduce [_ f init]
(with-open [rdr r]
(loop [line (.readLine rdr) acc init]
(if (reduced? acc)
(if line
(recur (.readLine rdr)
(f acc line))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment