Namely, while

Thread @ f[{a, b}, {x, y}]


{f[a, x], f[b, y]}

the InverseThread (if it existed) should reverse the process that

InverseThread @ {f[a, x], f[b, y]}


f[{a, b}, {x, y}] 
  • 17
    $\begingroup$ Thread[{f[a, x], f[b, y]}, f]. $\endgroup$ – Szabolcs Nov 1 '16 at 9:13

Let's make this a little more challenging:

invThread[body : _[h_[___] ..]] :=
  Replace[Thread[body, h], _[x_ ..] :> x, {1}]

f[{a, b}, {x, y}, z];
% // Thread
% // invThread
{f[a, x, z], f[b, y, z]}

f[{a, b}, {x, y}, z]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.