On Sat, Jul 30, 2011 at 2:25 PM, Ben <berndhe...@gmx.de> wrote: > Hi, > > I'm new in the community and new to Clojure and both a really great. A > big thanks to Rich Hickey and everyone else involved. > > I have a question that refers to an example Stuart Halloway used in > "Programming Clojure". There he defines the whole numbers as fn: > > (defn whole-numbers [] (iterate inc 1)) > > If I use it like this at the REPL > > (take 99999999 (whole-numbers)) > > I get: > Java heap space [Thrown class java.lang.OutOfMemoryError] > > This unexpectedly is the same result that I expectedly get when > binding whole-numbers to a top-level var and use a huge portion of > that. Since whole-numbers is lazy I expected it to run for a certain > amount of time but never to run out of memory. Has this anything to do > with using the function at the REPL or is there another reason for > that? > > With kind regards > Ben >
Hi, the lazy sequence returned is a caching one... so I guess that the cache blows the heap... Lars -- Mystische Erklärungen: Die mystischen Erklärungen gelten für tief; die Wahrheit ist, dass sie noch nicht einmal oberflächlich sind. -- Friedrich Nietzsche [ Die Fröhliche Wissenschaft Buch 3, 126 ] -- 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