JuliaLang/julia — pull request #7215 by ninjin (2014-06-11 07:29:26+00:00)
Title: RFC: Optional start argument for `enumerate`

Credit where credit is due, this was inspired by the `start` key-word added in Python 2.6 for the "same" function.

This enables us to use enumerate from arbitrary starting-points:

julia> [a for (a, b) in enumerate(1:3, 0)]
3-element Array{Int64,1}:
0
1
2

I also took the opportunity to allow for any number to be used, so, floats anyone?:

julia> [a for (a, b) in enumerate(1:3, -1.0)]
3-element Array{Float64,1}:
-1.0
0.0
1.0

There is one minor wart though, I am not sure what I think about:

julia> [a for (a, b) in enumerate(1:3, true)]
3-element Array{Any,1}:
true
2
3

But I suspect this is more of an issue with `true` being a `Number`, which has its upsides and downsides.

Tests included. Any and all feedback is as always most welcome.