I have three lists, e.g.
list1 = {{a,b,...}};
list2 = {{1,2},{3,4},...};
list3 = {{x,y},{z,w},...};
and a function
f[x_,y_]:=(* whatever it does *);
I need to get
{{f[a,1],f[a,2],...},{f[b,3],f[b,4],...}}
and
{f[{1,2},{x,y}],f[{3,4},{z,w}],...}
using built-in functions if possible (or in other fast way).
Answer
There are many closely related topics but I've failed to find a duplicate.
MapThread[Thread @* f, {First @ list1, list2}]
MapThread[f, {list2, list3}]
{{f[a, 1], f[a, 2]}, {f[b, 3], f[b, 4]}}
{f[{1, 2}, {x, y}], f[{3, 4}, {z, w}]}
Comments
Post a Comment