Being a newcomer to Mathematica, I have the following question.
Given
x = Range@9~Partition~3;
and
y = {a, b, c};
I want to combine x
and y
so that
result = {{a, 1, 2, 3}, {b, 4, 5, 6}, {c, 7, 8, 9}};
I have written
MapPrepend[a_, b_] := Prepend[a[[#]], b[[#]]] & /@ Range@Length@b
which does the job, but I wonder if there are other, more functional solutions?
Probably this question has already been answered. In this case it would be very nice if you just would direct me to the links.
Join[{y}, Transpose[x]] // Transpose
? $\endgroup$MapThread[Prepend, {x, y}]
$\endgroup$