I think this is the use case for a Reversed
wrapper that constructs a range when getindex
is called:
struct Reversed{T<:AbstractArray}
A::T
end
Base.getindex(a::Reversed, i::Int) = a.A[end-i+1]
v = [1, 2, 3]
a = Reversed(v)
a[1] # 3
push!(v, 4)
a[1] # 4