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 to '(0) the first time; it should evaluate to '(0 0) since there are 2 cons statements. That's the point I'm stuck on; any help would be gratefully received.
On Sun, Mar 9, 2014 at 12:54 PM, Asfand Yar Qazi <ayq...@gmail.com<javascript:> > > wrote: > >> 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. In particular, I do not >> understand what the recursive call to fib-seq will return when the sequence >> is lazily evaluated. >> >> Here's my understanding so far: >> >> The first time fib-seq is invoked, it has no head, and the function is >> the tail. So we go into the first collection, where we append 0 and 0 to >> fib-seq, which then '(0 0) . This is then mapped with the second >> collection, which (because fib-seq has not returned anything yet) is '(1) . >> Shouldn't map then raise an error because it is effectively being called >> as (map + (0 0) (1)) ? >> >> I would be very grateful for any insights. >> >> Thanks >> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@googlegroups.com<javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+u...@googlegroups.com <javascript:> >> 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+u...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Kind Regards, > Atamert Ölçgen > > -+- > --+ > +++ > > www.muhuk.com > -- 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/d/optout.