On Apr 30, 2013 5:32 AM, "Liao Pengyu" <arise...@gmail.com> wrote:
>     (def fib
>       (lazy-seq
>         (concat [0 1] (map + fib (rest fib)))))
>     (take 10 fib) ;; Bomb

The expression (rest fib) forces fib, which is the lazy seq you are already
trying to force when you eval (rest fib).

>     (def fib
>       (concat [0 1] (lazy-seq (map + fib (rest fib))))) ;; Works well

Whereas here, fib has already been forced when you call (rest fib),

>     (def fib
>       (lazy-cat [0 1] (map + fib (rest fib)))) ;; Works well

And here forcing fib doesn't eval (rest fib).

> All of the above program using lazy-seq

As you have seen, lazy-seq is not a silver bullet.

--
Stephen Compall
If anyone in the MSA is online, you should watch this flythrough.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to