On Wed, Nov 3, 2010 at 2:35 AM, Meikel Brandmeyer <m...@kotka.de> wrote: > Hi, > > On 3 Nov., 00:40, Rasmus Svensson <r...@lysator.liu.se> wrote: > >> I think the problem is that this reduction will build an expression like >> this: >> >> (map + ... (map + ... (map + ... (map + ... <one million nesting >> levels>)))) >> >> When clojure tries to realize an element of the resulting lazy seq, >> every level will result in a nested method call, which will eventually >> blow the stack. > > Exactly. Much better than my try on an explanation. The doall in my > example realises each sequence as it is created by reduce. Hence this > deep nesting level of calls cannot happen.
Thank you both for the explanation. I hadn't realized that reduce could work with lazy sequences in that way. I figured it was doing the equivalent of a "doall" already for each element of the sequence, but apparently not. :-) So now I see how the nesting can happen. Thanks! -John -- 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