I am not sure exactly how preduce differs from normal reduce, but
reduce is not a lazy operation, so it will result in the realization
of a lazy seq passed to it.

On Sun, Feb 8, 2009 at 2:13 PM, Jeffrey Straszheim
<straszheimjeff...@gmail.com> wrote:
> I have this piece of code:
>
> (defn- run-work-elements-in-parallel
>   "Runs a group of work elements in parallel. Returns an extended database."
>   [elements database]
>   (assert (set elements))
>   (let [[rec simp] (separate :recursive elements)
>         results-simp (pmap #(run-simple-work-element % database) simp)
>         results-rec (map #(run-recursive-work-element % database) rec)
>         results (concat results-simp results-rec)]
>     (preduce union (cons database results))))
>
> The exact details aren't important.
>
> The let bindings results-simp, results-rec, and results are each a lazy
> stream.  They can get quite large.  Assuming preduce can iterate over them,
> is binding them in the let statement stopping them from getting garbage
> collected?
>
> If so, is the best solution to wrap them in a (fn [] ...) and then use them
> like (results)?
>
> Thanks
>
> >
>



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to