it would be nice to have the ability to enumerate from any index like in python
now:
it = "hello"
for (i,el) in enumerate(it)
@show i
end
shows i=1,2...
would be nice to have:
it = "hello"
for (i,el) in enumerate(it,10) # or enumerate(10,it)
@show i
end
shows i=10,11...
It may also be useful to enumerate only up to a specific index. Perhaps keyword arguments like from= and to= could be used for this, e.g. enumerate(it, from=3, to=10). (Or maybe start and stop.) This functionality could probably be implemented fairly easily using take and drop from Base.Iterators.
Seems like this can be accomplished simply and efficiently with zip(countfrom(n), x). See discussion in linked PR.
Note that starting from a specific index isn't really easy with the current iterators interface: next isn't guaranteed to accept the linear index as its state argument. So a fully generic implementation would have to call next i times to get the element number i. It would be nice to add an ind2state function which could be overridden for types which can offer a more efficient approach. That would also fix https://github.com/JuliaLang/julia/pull/18668 (see https://github.com/JuliaLang/julia/pull/18668#discussion_r80393729).
I would like to work on this issue, please guide me how to proceed.
You implement the function, write tests for it and then make a Pull Request with the changes.
https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md is a good read.
Most helpful comment
Seems like this can be accomplished simply and efficiently with
zip(countfrom(n), x). See discussion in linked PR.