Skip to content

Instantly share code, notes, and snippets.

@pjb3
Created February 22, 2012 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjb3/1886007 to your computer and use it in GitHub Desktop.
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?
(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))
(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