Created
February 22, 2012 16:56
-
-
Save pjb3/1886007 to your computer and use it in GitHub Desktop.
I expect these to be the same, the fn one works but the recur one gives me a java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 0 args, got: 1. Any ideas?
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 batch-lazy-seq | |
([] (batch-lazy-seq 1)) | |
([start] | |
(let [batch-size 10 | |
end (+ start batch-size)] | |
(println "Loading batch" start "-" (- end 1)) | |
(lazy-cat | |
(vec (range start end)) | |
(batch-lazy-seq end))))) | |
(doseq [n (batch-lazy-seq)] | |
(println n)) |
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 batch-lazy-seq [] | |
(loop [start 1] | |
(let [batch-size 10 | |
end (+ start batch-size)] | |
(println "Loading batch" start "-" (- end 1)) | |
(lazy-cat | |
(vec (range start end)) | |
(recur end))))) | |
(doseq [n (batch-lazy-seq)] | |
(println n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment