Iterator product


#1

Good afternoon,

I wish to use collect(Iterators.product(iter, ...)) but I need the input to be adaptive. For example suppose n=2, then I want the code to run

iter = 0:3
collect(Iterators.product(iter, iter))

and if n=5, then

iter = 0:3
collect(Iterators.product(iter, iter, iter, iter, iter))

I tried to use different things, for instance repeat, but nothing worked. Any suggestions ?

Thank you very much for your help! :slight_smile:


#2

You should be able to say collect(Iterators.product(Iterators.repeated(iter, n)...)).

(And if you using .Iterators, then you can say this more tersely as collect(product(repeated(iter, n)...)).


#3

Oh I see, I did not use repeat through Iterator! Thank you