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  
consumes stack. Instead of defining a function, you might want to use  
def. This seems to work:

(def triangle-numbers (lazy-cat [1] (map + (iterate inc 2) triangle- 
numbers)))


cheers,
gert


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to