Re:Numbering should start at zero: E.W. Dijkstra
by UncleEntity on Friday March 21, 2025 @09:21AM
(#43435347)
So you're saying a negative index value should work like a count of elements to return and not an index?
Then you couldn't do thing like l[-4:-2] to get a range of elements which seems slightly useful.
`l[:n]` gives you the first `n` elements of the list `l`. Ideally `l[-n:]` would give you the last `n` elements - but that doesn't work when `n` is zero.
I believe this is why C# introduced a special "index from end" operator, `^`, so you can refer to the end of the array as `^0`.