This also fails:

(defn splode [n]
  (doseq [document (filter #(= % 20) (map inc (range n)))]))

Looking at the heap dump, I see that the first item for which the filter returns true is the root of the chain of lazy cons's that's being kept.

The filter is constructing a lazy-cons from the first of a lazy-cons returned by map.

--Steve

On Dec 6, 2008, at 9:29 PM, MikeM wrote:


Some more experimentation:

(defn splode3 [n]
 (with-local-vars [doc-count 0]
   (doseq [document (filter #(= % (- n 1)) (map inc (range n)))]
     (var-set doc-count (inc @doc-count)))
   'done))

which does not blow up with (splode3 1000000000).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to