I played around with some code, trying to explore the memory problems
with 'filter' that is discussed in another thread, when I noticed an
unexpected behavior from 'nth'.

Behold:

user=> (nth (repeatedly (fn [] 0)) 10000000)
java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0)
user=> (defn xth [coll i]
  (if (zero? i) (first coll) (recur (rest coll) (dec i))))
#'user/xth
user=> (xth (repeatedly (fn [] 0)) 10000000)
0

I could be wrong, but I don't think 'nth' should blow the heap here.

-- 
Venlig hilsen / Kind regards,
Christian Vest Hansen.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to