# How to turn two lists of unequal lengths into coordinates?

I have the following two lists;

a = {-1.8, -1.6, -1.4, -1.2, -1., -0.7, -0.6, -0.4, -0.2, 0., 0.2, 0.4,
0.6, 0.8, 1., 1.2, 1.4, 1.6, 1.8}
b = {.2, .4, .6, .8, 1., 1.2, 1.4, 1.6, 1.8}


I want to turn this into coordinate points where each ai value is matched to each bi. Essentially (-1.8,.2),....,(-1.8,1.8) would be the first 9 points and it would create points for all 19 values of a.

• Outer[List, a, b] // Flatten[#, 1] & – Bob Hanlon Nov 25 '19 at 0:59

Perhaps Tuples[{a, b}]?

See Tuples.

• Would have to Partition that if OP wanted 19 separate lists. – Rohit Namjoshi Nov 25 '19 at 0:59
• @RohitNamjoshi Yep, and we'd have to Flatten yours if the OP doesn't. – Michael E2 Nov 25 '19 at 1:05

You can also use Distribute:

Distribute[{a, b}, List]

Join @@ (Thread[{#, b}] & /@ a)


Here is one way to do that

Transpose[{ConstantArray[#, 9], b}] & /@ a