Iterator product

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:

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)...)).

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

1 Like