0

I have a set of linear arrays:

[0, 2, 4]
[3, 7, 13, 16, 18]
[1, 11, 12, 17]
[5, 6, 14, 15]

I want to do the equivalent of a SQL cross join of all of these sets onto each other, so that I can create a matrix whose rows would be something like:

[0, 3, 1, 5] (0th entry in each array)
[0, 3, 1, 6] (0th 0th 0th 1st)
[0, 3, 1, 14] (0th 0th 0th 2nd)
[0, 3, 1, 15] (0th 0th 0th 3rd)
[0, 3, 2, 5] (0th 0th 1st 0th)
...
[4 18 17 15] (last entry in each array)

The brute force way I can think of is nested for-loops which seems hugely inefficient.

Is there a simple way to do this in python? I'm still learning zip and map and list comprehension and thought maybe there's some way using those, but I've been staring at this for a while and could use a nudge.

Thanks for any help!

user4110656
  • 23
  • 1
  • 5

0 Answers0