Earlier quoted context omitted.
Use them like the first-class vectors they are. You can use _any_ array manipulation on ranges.
please take a look at my rant below, do not want to write it twice
Say I have an index `idx` into a very large array and I want to select a symmetric window of `N` indices before and after that index. In Julia:
A[idx .+ (-N:N)]
In Python: A[idx-N:idx+N+1]
Python cannot even index lists by ranges (or other lists). And if I go out of bounds, well, it'll happily just give me back a list of a size I didn't expect.Heck, in Julia I can even easily determine what the OOB behavior should be. It's an error above, but I can easily change it. This, for example, will ensure no indices go out of bounds by repeating the final endpoint as necessary.
A[clamp.(idx .+ (-N:N), 1, end)]
Sometimes you want to work in terms of the fenceposts, and sometimes by the length of the fence. There certainly are cases where 0-based offsets are nice — or even arbitrary offsets. In those cases we have OffsetArrays.