What I am trying to get is all the possible values given an array [0, 1, 2]
and a number n
. The result for n=3
would be:
[0,0,0]
[0,0,1],
[0,0,2]
[0,1,0]
...
[2,2,2]
So basically all the numbers in base 3 given as separate elements in an array.
I have been trying to get this output by using Base.Iterators.product([0,1,2],[0,1,2],[0,1,2])
and this does indeed work but I’m having trouble finding a way to be able to do so programatically, as I can’t pass the arguments to product
separately.
I tried generating the list of arrays by using repeat([0,1,2], 1, n)
and this does give me a matrix of n columns with each being one [0, 1, 2]
arrays, but I can’t find a way to pass each of these columns separately as input to product()