Hi!

Could someone please help me understand why the following causes a
java.lang.OutOfMemoryError: Java heap space for large n:s (100000
works fine, 1000000 does not).

(def integers (iterate inc 1))

(defn limited-reduce [fn coll n]
  (loop [c coll i n result 0]
  (if (zero? i)
    result
  (recur
    (rest c)
    (dec i)
    (fn result (first c))))))

(limited-reduce + integers 100000)

Many thanks!

/Patrik

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