Re: java.lang.OutOfMemoryError when consuming many whole-numbers

2011-08-01 Thread Ben
Limiting *print-length* keeps the OutOfMemoryError away, but I guess it would leave me - when testing more complicated and obscure functions - insecure whether the returned sequence really is a lazy one or will blow up the memory instead. But good to know anyway ... I guess the println function is

Re: java.lang.OutOfMemoryError when consuming many whole-numbers

2011-08-01 Thread Lars Heidieker
On Sat, Jul 30, 2011 at 2:25 PM, Ben 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

Re: java.lang.OutOfMemoryError when consuming many whole-numbers

2011-08-01 Thread Alex Osborne
Ben writes: > (defn whole-numbers [] (iterate inc 1)) > > If I use it like this at the REPL > > (take (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 t

Re: java.lang.OutOfMemoryError when consuming many whole-numbers

2011-08-01 Thread Dmitry Gutov
When I do that, the REPL starts printing the sequence, filling screens after screens with numbers. By doing that, it realizes the printed part of the sequence, which will eventually lead to an OOM error, since it probably holds on to the reference to the start of the sequence. Doing (set! clojure.

java.lang.OutOfMemoryError when consuming many whole-numbers

2011-08-01 Thread Ben
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 in