parallel map and dot product

Hudson, Rick rick.hudson at
Thu Apr 4 12:06:40 PDT 2013

In this case it is the same as with a normal array.

function dotProduct(v1, v2) {
return (e, i) {return e*v2[i];}).reduce(function (a, b) {return a+b;});

-        Rick

From: es-discuss-bounces at [mailto:es-discuss-bounces at] On Behalf Of Norm Rubin
Sent: Thursday, April 04, 2013 2:31 PM
To: es-discuss at
Subject: parallel map and dot product

I've started to read through the parallel JavaScript  proposal  and have a novice question
How would you write a dot product

P1 = parallelArray(1,2,3)
P2 = ParallelArray(4,5,6)

We want to compute
1*4 + 2*5 + 3*6

As far as I can tell, you need a reduce to do the sums, so you first need to construct
 P12 = ParallelArray(1*4, 2*5, 3*6)

Is there a way to generate this using map?

This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list