Strip one element off the end of a `OneTo` (or `UnitRange`)

Say that I have the following pseudo-code:

    for i in 1:length(array)-1
     array[i+1] = some_function(array[i])

Now I want to rewrite the loop using eachindex instead of 1:length (because it is simpler, and because that array might need to be 0-indexed at some point). Is there a function operating on OneTo, or on UnitRange, which changes the interval [a:b] to [a+δa:b+δb] ? (I rapidly looked at "range.jl" and saw no such function.)

(I would be tempted to define Base.:-(r::OneTo, d::Int) = OneTo(r.stop-d), so that 1:length(array) could be replaced by eachindex(array) even when followed by an offset. But that addresses only one end of the problem.)

Indexing is one way: r[begin:end-1]. But if you’re going to operate on eachindex(A), you should probably be prepared to get CartesianIndices back… and while you can also index into them with [begin:end-1], it’ll leave the performance wanting (to put it mildly).

You could do Iterators.take(eachindex(A), length(A)-1).