I can't understand why this lazy-seq causes a stackoverflow, and why not when you pass the sequence to dorun:
(defn very-lazy [s]
(lazy-seq
(if (seq s)
[(first s) (very-lazy (rest s))]
[])))
(dorun (very-lazy (range 200000000)))
>nil
(take 2 (very-lazy (range 20000000))
>...(1577 (java.lang.StackOverflowError
If it's lazy then take 2
should cause the lazy seq to iterate only two times, why doesn't happen and why dorun works?