On Fri, Dec 19, 2008 at 4:35 PM, Michael Wood <esiot...@gmail.com> wrote: > On Fri, Dec 19, 2008 at 4:32 PM, Rich Hickey <richhic...@gmail.com> wrote: >> >> On Dec 19, 8:59 am, "Michael Wood" <esiot...@gmail.com> wrote: [...] >>> There is a function called partition in Clojure's core.clj that does >>> this, except it does not pad, but rather discards any incomplete >>> groups. It's recursive, though, so it runs out of heap on large >>> sequences like (iterate inc 1). >>> >> >> That's not true - partition is lazy: >> >> ;with -Xmx128M >> >> (last (partition 2 (take 100000000 (iterate inc 1)))) >> -> (99999999 100000000) > > hmmm... if I do this: > > user=> (partition 2 1 (iterate inc 1)) (.printStackTrace *e) > > it ends like this: > > [...] > 57) (587257 587258) (587258 587259) (587259 587260) (587260 587261) > (587261 587262) (587262 587263) (587263 587264) (587264 587265) > (587265 587266) (587266 587267) (587267 587268) (587268 587269) > (587269 587270) (587270 587271) (587271 587272) (587272 587273) > (587273 587274) user=> java.lang.OutOfMemoryError: Java heap space [...]
Actually, I suppose that's because it's printing the whole thing out? -- Michael Wood <esiot...@gmail.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 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 -~----------~----~----~----~------~----~------~--~---