Re: The order of lazy-seq

2013-05-02 Thread Gary Verhaegen
lazy-seq only delays its own evaluation, it is not "recursive" : (lazy-seq [0 1 2 3]) will evaluate the whole vector as soon as it is forced. This means that it should wrap the tail of the lazy sequence you are building. Consequently, I find that the easiest way to use lazy-seq is as a second argu

Re: The order of lazy-seq

2013-05-01 Thread Stephen Compall
On Apr 30, 2013 5:32 AM, "Liao Pengyu" 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 >

The order of lazy-seq

2013-04-30 Thread Liao Pengyu
Code: (def fib (lazy-seq (concat [0 1] (map + fib (rest fib) (take 10 fib) ;; Bomb Got the error message: _StackOverflowError clojure.lang.RT.more (RT.java:589)_ And the following solutions works well: (def fib (concat [0 1] (lazy-seq (map + fib (rest fib)