Re: Need help understanding a lazy sequence function

2014-03-10 Thread Asfand Yar Qazi
Hi, On Sunday, 9 March 2014 14:58:47 UTC, Atamert Ölçgen wrote: Hello, (take 1 fib-seq) = (1) Which can also be seen as[*] (map + (0) (1)) (map + '(0) '(1)) = (1) Makes sense? I'm afraid it still doesn't make sense; I still don't understand how (cons 0 (cons 0 fib-seq)) evaluates

Re: Need help understanding a lazy sequence function

2014-03-10 Thread Alan Forrester
On 10 March 2014 10:26, Asfand Yar Qazi ayq...@gmail.com wrote: Hi, On Sunday, 9 March 2014 14:58:47 UTC, Atamert Ölçgen wrote: Hello, (take 1 fib-seq) = (1) Which can also be seen as[*] (map + (0) (1)) (map + '(0) '(1)) = (1) Makes sense? I'm afraid it still doesn't make sense;

Re: Need help understanding a lazy sequence function

2014-03-10 Thread Asfand Yar Qazi
On Monday, 10 March 2014 11:35:30 UTC, Alan Forrester wrote: According to the documentation for map http://clojuredocs.org/clojure_core/clojure.core/map (map + x y) where x and y are two collections adds the first element of x to the first element of y, the second element of x to the

Re: Need help understanding a lazy sequence function

2014-03-10 Thread Frank Behrens
Hello, I'm trying to understand the lazyness, how they work, how to create them, how to avoid pre-realisation. Can someone point me to which documentation would be helpful, where do I find it ? Frank Am Montag, 10. März 2014 13:16:00 UTC+1 schrieb Asfand Yar Qazi: On Monday, 10 March 2014

Re: Need help understanding a lazy sequence function

2014-03-10 Thread Gary Trakhman
If you haven't seen the impl yet, it's relatively small and simple: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L642 https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LazySeq.java Chunked seqs are more complex, but they're basically a performance

Need help understanding a lazy sequence function

2014-03-09 Thread Asfand Yar Qazi
Hi, I'm trying to understand the following function (from http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci#Self-Referential_Version): (def fib-seq (lazy-seq (map + (cons 0 (cons 0 fib-seq)) (cons 1 fib-seq I'm trying to understand how this works.

Re: Need help understanding a lazy sequence function

2014-03-09 Thread Atamert Ölçgen
Hello, (take 1 fib-seq) = (1) Which can also be seen as[*] (map + (0) (1)) (map + '(0) '(1)) = (1) Makes sense? (take 2 fib-seq) = (1 1) Here the recursive definition (note that it's not a function, fib-seq simply a Var that holds a LazySeq object) comes into play. We already know the