Re: fibonacci sequence using lazy-cat

2009-07-29 Thread Stuart Halloway
While fibs is a nice small example, it is not idiomatic Clojure. Pointing the fibs var to the head of the list keeps the whole list in memory as it realizes. Better is to expose fibs as a *function* return the sequence, so the head is not retained. (defn fibo [] (map first (iterate (fn [[

Re: fibonacci sequence using lazy-cat

2009-07-29 Thread swaroop belur
cool - thanks guys for the detailed reply. crystal clear now -:) Thx swaroop --~--~-~--~~~---~--~~ 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

Re: fibonacci sequence using lazy-cat

2009-07-29 Thread Baishampayan Ghose
Swaroop, > Just started learning clojure recently - initial examples were easy to > understand, until I found this example > > fibonacci sequence using lazy-cat : > (def fibs (lazy-cat [0 1] (map + fibs (rest fibs > > I am trying to understand how this works ..not su

Re: fibonacci sequence using lazy-cat

2009-07-29 Thread Lauri Pesonen
Hi swaroop, 2009/7/29 swaroop belur : > > fibonacci sequence using lazy-cat : > (def fibs (lazy-cat [0 1]   (map + fibs (rest fibs > > I am trying to understand how this works ..not sure i fully comprehend > it. > > Can anyone please explain how clojure evaluates thi

fibonacci sequence using lazy-cat

2009-07-29 Thread swaroop belur
Hello all, Just started learning clojure recently - initial examples were easy to understand, until I found this example fibonacci sequence using lazy-cat : (def fibs (lazy-cat [0 1] (map + fibs (rest fibs I am trying to understand how this works ..not sure i fully comprehend it. Can