A good way to iterate through sequences?

The only thing that bothers me with Base.Iterators.product([1:3 for i in 1:4]...) is that the generator generates the sequences in a 3x3x3x3 array. Is there a way to generate a flat array?

I know I can vec(collect(...)) it, but that also materializes the iterator, which I don’t want. vec applied on the generator directly doesn’t work. I also tried Iterators.flatten, but that flattens too much (even the tuples get flattened).

Update: I found my answer on the Slack:

collect(Iterators.flatten((Base.Iterators.product((1:3 for i in 1:4)...),)))
1 Like