apply does exactly what you're describing...it treats a collection as
several arguments:
(apply + [1 2 3 4]) is equivalent to: (+ 1 2 3 4)
=> 10
so (pmap + '(1 2 3) '(4 5 6) '(7 8 9) ) is equivalent to: (apply pmap +
['(1 2 3) '(4 5 6) '(7 8 9)])
no need for macros and stuff...actually apply is a macro...
hope that helps
Jim
On 02/02/13 13:35, Leandro Moreira wrote:
Hi Jim,
Thanks for your help & time, how do I apply instead of reduce?
I was looking the documentation of pmap and it says
*(pmap fn coll & colls)*
So I think we can use pmap this way:
*(pmap + '(1 2 3) '(4 5 6) '(7 8 9) )*
Which gives us the result: *(12 15 18)*
My intention it's only to *use range and partition to substitute
that*, but I think partition-all doesn't work like separated argument
as list, instead. When we type:
(*partition-all 5 (range 1 20))*
Results in this:
*((1 2 3 4 5) (6 7 8 9 10) ...*
There is any way of *transforming* (maybe a macro or destruct way)
this "list" in *several colls argument as expected by pmap* signature
(fn coll & colls)?
On Saturday, February 2, 2013 11:10:35 AM UTC-2, Jim foo.bar wrote:
Use this:
(pmap #(reduce + %) (partition-all 5 (range 1 20)))
OR as you yourself said you can use 'apply' instead of reduce
Jim
On 02/02/13 12:31, Leandro Moreira wrote:
Hi there,
I have this:
*user=>* (partition-all 5 (range 1 20))
((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 15) (16 17 18 19))
And I would like to apply the *pmap* over the partitions,
something like: (the line bellow doesn't work)
*user=>* (pmap + (partition-all 5 (range 1 20)))
/I would like to have this (pmap + (1 2 3 4 5) (6 7 8 9 10) (11
12 13 14 15) (16 17 18 19)) instead of this (pmap + ((1 2 3 4 5)
(6 7 8 9 10) (11 12 13 14 15) (16 17 18 19)))/
How can I apply pmap over a partition-all result?
If it's possible, by doing that am I distributing the load better
than if I used the pmap with the whole list?
Thanks
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
<javascript:>
Note that posts from new members are moderated - please be
patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com <javascript:>
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+u...@googlegroups.com <javascript:>.
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.
--
--
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.