1
$\begingroup$

I have an expression like this

F[G[1, b], G[3, y], G[4, y], G[5, u]]

that I would like to Transpose to obtain

G[F[1, 3, 4, 5], F[b, y, y, u]]

Since Transpose doesn't act on expressions (with heads different from List), what is the built-in function that makes this transformation?

I can do something like

G@@F@@@Transpose[F[G[1, b], G[3, y], G[4, y], G[5, u]] /. F|G->List]

but I'd rather use something lower level than that.

$\endgroup$

closed as off-topic by QuantumDot, m_goldberg, MarcoB, Henrik Schumacher, halirutan Jul 10 '18 at 23:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – QuantumDot, m_goldberg, MarcoB, Henrik Schumacher, halirutan
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Thread[F[G[1, b], G[3, y], G[4, y], G[5, u]], G]. $\endgroup$ – march Jul 9 '18 at 16:49
6
$\begingroup$

Thread does that:

Thread[F[G[1, b], G[3, y], G[4, y], G[5, u]], G]

G[F[1, 3, 4, 5], F[b, y, y, u]]

$\endgroup$
  • $\begingroup$ Yep, that's it thanks! $\endgroup$ – QuantumDot Jul 8 '18 at 17:59

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