Re: A Failure To Understand lazy-seq

2017-09-05 Thread Dan Burton
I'll try and explain. This explanation isn't perfectly rigorous, but may be close enough. (def fibs (lazy-seq (cons 0 (cons 1 (map +' fibs (rest fibs)) This creates a thunk, deferring execution of the body of `lazy-seq`. (first fibs) This forces the thunk, let's call it THUNK1. In order to fo

A Failure To Understand lazy-seq

2017-09-04 Thread mrwizard82d1
I'm trying to understand infinite sequences. Wikipedia defines an implementation of the Fibonacci sequence as: (def fibs (cons 0 (cons 1 (lazy-seq (map +' fibs (rest fibs)) However, when I wrote fibs in the repl as: (def fibs (lazy-seq (cons 0 (cons 1 (map +' fibs (rest fibs)) executin