Why do you use: (reduce #(conj %1 (f %2)) [] p)
Instead of: (mapv f p) ? 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))) - James On 1 June 2013 12:49, Jim - FooBar(); <jimpil1...@gmail.com> wrote: > Hi all, > > I've been using the following fn quite extensively lately and I'm just > wondering if you can see any flaws with it...or perhaps something that can > be done better? I generally find that this performs better than a bare pmap > and in fact it often performs better than my 'pool-map' (which I'm not > showing here) which is backed by executors. > > (defn mapr > "A basic map-reduce style mapping-function. Will partition the data > according to p-size and assign a future to each partition (per pmap)." > ([f coll p-size] > (->> coll > (partition-all p-size) > (pmap (fn [p] (reduce #(conj %1 (f %2)) [] p)) ) > (apply concat)) ) ;;concat the inner vectors that represent the > partitions > ([f coll] > (mapr f coll (+ 2 cpu-no)))) > > thanks, > > 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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/**group/clojure?hl=en<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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > . > For more options, visit > https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> > . > > > -- -- 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.