On 01/06/13 13:06, James Reeves wrote:
Also, this looks a lot like what you can achieve with the reducers
library:
(r/fold p-size r/cat r/append! (r/map f (vec coll)))
well, for fork-join-based parallelism I was using this:
(defn fold-into-vec [chunk coll]
"Provided a reducer, concatenate into a vector.
Same as (into [] coll), but parallel."
(r/fold chunk (r/monoid into vector) conj coll))
(defn rmap
"A fork-join based mapping function that pours the results in a vector."
[f coll fj-chunk-size]
(fold-into-vec fj-chunk-size (r/map f (vec coll))))
where 'fold-into-vec' is taken from
http://www.thebusby.com/2012/07/tips-tricks-with-clojure-reducers.html
basically, the only difference is the reducing/combining fns...you
suggest r/cat & r/append! whereas I'm using (r/monoid into vector) and conj.
from a quick look in reducers.clj it seems that cat uses an ArrayList
underneath...is this why it's considered high-performance? I also see
there is 'foldcat' which is (foldcatappend!coll) - exacly what you 're
sugegsting! interesting stuff...I'll try it now :)
Jim
--
--
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
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.