Whats the point of lazy-seq in clojure?

Posted by dbyrne on Stack Overflow See other posts from Stack Overflow or by dbyrne
Published on 2010-05-31T15:59:48Z Indexed on 2010/05/31 16:03 UTC
Read the original article Hit count: 288

I am looking through some example Fibonacci sequence clojure code:

 (def fibs (lazy-cat [1 2] (map + fibs (rest fibs))))

I generally understand what is going on, but don't quite understand the point of lazy-cat. I know that lazy-cat is a macro that is translating to something like this:

(def fibs (concat (lazy-seq [1 2]) (lazy-seq (map + fibs (rest fibs))))) 

What exactly is lazy-seq accomplishing? It would still be evaluated lazily even without lazy-seq? Is this strictly for caching purposes?

© Stack Overflow or respective owner

Related posts about clojure

Related posts about lazy-evaluation