Say I have 4 arrays:
a = [1,2,3]
b = [1,2,3,4]
c = [1,2,3,4,5]
d = [1,2,3,4,5,6]
I could iterate like so:
tups = []
for i in a:
for j in b:
for k in c:
for l in d:
t = i,j,k,l
tups.append(t)
tups
would then be an array of tuples and will look something like this:
1,1,1,1
1,1,1,2
1,1,1,3
...
1,1,1,6
...
This seems rather long winded and I feel that there should be a faster/more efficient way of doing this, but I'm not really a python expert.
How can I make this faster, without looping over each array? Is there some functional approach which I can use?