Skip to main content
1 of 2
eldo
  • 83.1k
  • 6
  • 72
  • 202

Merging to lists

Being a newcomer to Mathematica, I have this 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.

eldo
  • 83.1k
  • 6
  • 72
  • 202