# 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 ?

• how about ParallelMap[{First[#], f @@ Rest[#]} &, tab] Jan 13, 2015 at 16:47

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

{{x, y, z}, {x, y, z},
{x, y, z}, {x, y, z}}

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

{{x, f[y, z]}, {x, f[y, z]},
{x, f[y, z]}, {x, f[y, z]}}


See Apply and SlotSequence for clarification.

Calling

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


We have

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