Re: Lazy sequence blows starck. Why?

2009-07-03 Thread David Cabana
On Jul 3, 11:11 pm, Gert Verhoog wrote: > This seems to work: > > (def triangle-numbers (lazy-cat [1] (map + (iterate inc 2) triangle- > numbers))) > > cheers, > gert Gert, Your proposed change works very well. It's interesting that a (seemingly) small change makes a huge difference in perfo

Re: Lazy sequence blows starck. Why?

2009-07-03 Thread Gert Verhoog
On 4/07/2009, at 2:42 PM, David Cabana wrote: > (defn triangle-numbers [] > (lazy-cat [1] (map + (iterate inc 2) (triangle-numbers > > This second approach dies with a stack overflow. Can anyone shed some > light on why? The last (triangle-numbers) is recursive, but without loop/recur this

Lazy sequence blows starck. Why?

2009-07-03 Thread David Cabana
I'm working one of the Euler project problems, which asks for the first triangle number with more than 500 divisors. I thought it might be fun to use lazy sequences, and tried two approaches. One worked, the other blew the stack. I'm trying to understand why the second approach fails. Here's the