I've seen the operation described in the title before (basically, swap the heads of the first two levels of an expression), but I can't find it...
Does anyone know the function (or idiom/incantation) for the operation I'm talking about?
Note that, in general, Thread doesn't do the described operation. E.g.:
Thread[X[Y[1, 2, 3]], Y] evaluates to
Y[X[1], X[2], X[3]] rather than the desired
Y[X[1, 2, 3]] The same thing goes for Map:
Map[X, Y[1, 2, 3]] (* Y[X[1], X[2], X[3]] *) I've tried many, many, many, many, many possibilities: Transpose[X[Y[1, 2, 3]], {1, 0}], Outer[X, Y[1, 2, 3], 0, Heads -> True], etc., etc.... without success, of course.
ReplaceAllnot be sufficient? $\endgroup$/. a_[b_[c___]] :> b[a[c]]for arbitrary fn names... $\endgroup$:>is what I was missing... $\endgroup$