I have an iterator. How do I iterator through a selection of it?
it = Iterators.product([[1,2,3],[1,2]]...)
iterates through all 6 values. But say I want to iterate starting with the 2nd value and end with the 5th value. How do I do that?
It’s a bit clumsy, but something like this:
julia> dropends(it, start, stop) = Iterators.drop(Iterators.take(it, stop), start - 1)
dropends (generic function with 1 method)
julia> foreach(println, dropends(it, 2, 5))
(Bonus thanks for showing that
foreach(println,it) are equivalent!)