# Incomplete Parallel Mapping

I am still struggling on how to nicely handle list operations in Mathematica, and perform simultaneously parallel computation. We consider a tab of the form

tab = {{x1,y1,z1},{x2,y2,z2},…,{xn,yn,zn}};

I know how to perform the following replacement

tab2 = tab /. {x_,y_,z_} -> {x,f[y_,z_]} ;

so that tab2 is of the form

tab2 = {{x1,f[y1,z1]},{x2,f[y2,z2]},…,{xn,f[yn,zn]}};

However, because f[y,z] is an expensive function to compute, I would like to construct tab2 in a parallel fashion. I tried using ParallelMap, but didn’t find a neat way of performing the calculation, mainly because it requires to perform an incomplete mapping.

How should one proceed in order to build-up in parallel the second list tab2 ? What would be the most efficient way to do it ?

=================

1

how about ParallelMap[{First[#], f @@ Rest[#]} &, tab]
– chris
Jan 13 ’15 at 16:47

=================

2

=================

tab = Table[{x[n], y[n], z[n]}, {n, 4}]

{{x[1], y[1], z[1]}, {x[2], y[2], z[2]},
{x[3], y[3], z[3]}, {x[4], y[4], z[4]}}

ParallelMap[{#, f[##2]} & @@ # &, tab]

{{x[1], f[y[1], z[1]]}, {x[2], f[y[2], z[2]]},
{x[3], f[y[3], z[3]]}, {x[4], f[y[4], z[4]]}}

See Apply and SlotSequence for clarification.

Calling

tab = {{x1,y1,z1},{x2,y2,z2},{xn,yn,zn}};

We have

ParallelMap[{First[#], f @@ Rest[#]} &, tab]