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 ?
ParallelMap[{First[#], f @@ Rest[#]} &, tab]
$\endgroup$