Skip to content

Instantly share code, notes, and snippets.

@hoeck hoeck/lazy rest
Created Jun 14, 2010

What would you like to do?
(defn lazy-foo
(lazy-seq (when (< 0 cnt)
(println "FOO: " cnt)
(cons cnt (lazy-foo (dec cnt)))))))
(let [s (lazy-foo 10)
x (rest s)])
=> FOO: 10
=> nil
(let [s (lazy-foo 10)
x (next s)])
=> FOO: 10
=> FOO: 9
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.