Created
March 7, 2010 04:31
-
-
Save hiredman/324145 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
(defn chunked-line-seq | |
"Returns the lines of text from rdr as a chunked[size] sequence of strings. | |
rdr must implement java.io.BufferedReader." | |
[#^java.io.BufferedReader rdr size] | |
(lazy-seq | |
(when-let [line (.readLine rdr)] | |
(chunk-cons | |
(let [chunk’ (chunk-buffer size)] | |
(chunk-append chunk’ line) | |
(dotimes [i (dec size)] | |
(when-let [line (.readLine rdr)] | |
(chunk-append chunk’ line))) | |
(chunk chunk’)) | |
(chunked-line-seq rdr size))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment