Skip to main content
5 of 5
Formatted code
MarcoB
  • 67.7k
  • 18
  • 96
  • 198
xy = {{x1, y1}, {x2, y2}, ...}
z = {z1, z2, ...}
xyz = Partition[Flatten[Riffle[xy, z]], 3]

and you're done. Riffle also works with just one z-value: it'll do exactly what you asked, after re-reading your question more carefully.

Explanation:

First, Riffle[list1, list2 **or** element, so just z1 works, too] makes

{ {x1, y1}, z1, {x2, y2}, z2, ...}

then, Flatten[list] makes

{ x1, y1, z1, x2, y2, z2, ... }

finally, Partition[list, 3] turns it into

{ {x1, y1, z1}, {x2, y2, z2}, ...}