On Wed, Jul 15, 2015 at 12:02 PM, Daniel Higginbotham <
[email protected]> wrote:

> Surely reducers/map should be faster, but it doesn’t seem like I’ve done
> something wrong? This is driving me crazy :)


It is much faster, and runs in parallel, if you use fold.

Try this;

(defn fold-into-vec [coll]
  "Provided a reducer, concatenate into a vector.
   Note: same as (into [] coll), but parallel."
  (r/fold (r/monoid into vector) conj coll))

So it should read as;
(defn reducer-test [nums]
   (fold-into-vec (r/map inc nums)))

Details here;
http://www.thebusby.com/2012/07/tips-tricks-with-clojure-reducers.html

Hope this helps

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
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
--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to