List structure transformation
Flatten /@ Thread[data, List, {2}]
{{x, y, a}, {x, y, b}, {x, y, c}, {x, y, d}, {x, y, e}}
Also:
Append @@@ Tuples[{{#}, #2}] & @@ data
{{x, y, a}, {x, y, b}, {x, y, c}, {x, y, d}, {x, y, e}}
ClearAll[dat]
dat = {{x, y}, {a, b, c, d, e}}
Append[dat[[1]], #] & /@ dat[[2]]
{{x, y, a}, {x, y, b}, {x, y, c}, {x, y, d}, {x, y, e}}
Also this may offer some added advantages
Table[Join[dat[[1]], {dat[[2, i]]}], {i, Length[dat[[2]]]}]
Seems like a good place to use MapThread
. Problem is that it wants both lists to be the same length. So use Table
to make it so.
{p, q} = {{x, y}, {a, b, c, d, e}}; MapThread[Append, {Table[p,Length[q]], q}]