This is an automated archive made by the Lemmit Bot.

The original was posted on /r/programminglanguages by /u/trolley813 on 2024-08-09 06:47:24+00:00.


Seriously, why not? I mean, considering left-open (instead of right-open, as usual) intervals - i.e. not a <= x < b, but a < x <= b . E.g. something like A[3:5] means A[4] and A[5] (including the end (5) but not the start (3)).

This way (for example) allows to “properly” deal with 1-based arrays, keeping the zero for the “never-exist” index (before-the-beginning - instead of hypothetical after-the-end index used e.g. in C++), like described here (e.g. when finding the index of an element, returning 0 for “not found” seems to be natural choice since comparing with zero is indeed “easier” than with everything else - 0 is false and everything else is true. When 0 is a valid index, one should use awkward things like -1).