1. 9
  1. 4

    Here is a related manuscript on the rationale behind half-open indexing, i.e., [begin, past-the-end): Why numbering should start at zero by Edsger W. Dijkstra.

    Quoting the relevant parts from it:

    To denote the subsequence of natural numbers 2, 3, …, 12 without the pernicious three dots, four conventions are open to us

    a) 2 ≤ i < 13
    b) 1 < i ≤ 12
    c) 2 ≤ i ≤ 12
    d) 1 < i < 13

    Are there reasons to prefer one convention to the other? Yes, there are. The observation that conventions a) and b) have the advantage that the difference between the bounds as mentioned equals the length of the subsequence is valid. So is the observation that, as a consequence, in either convention two subsequences are adjacent means that the upper bound of the one equals the lower bound of the other. Valid as these observations are, they don’t enable us to choose between a) and b); so let us start afresh.

    There is a smallest natural number. Exclusion of the lower bound —as in b) and d)— forces for a subsequence starting at the smallest natural number the lower bound as mentioned into the realm of the unnatural numbers. That is ugly, so for the lower bound we prefer the ≤ as in a) and c). Consider now the subsequences starting at the smallest natural number: inclusion of the upper bound would then force the latter to be unnatural by the time the sequence has shrunk to the empty one. That is ugly, so for the upper bound we prefer < as in a) and d). We conclude that convention a) is to be preferred.

    Stories with similar links:

    1. Blazing fast math rendering on the web via calvin 2 years ago | 10 points | 6 comments
    2. Incunabulum for the 21st century: Making the J interpreter compile in 2020 via calvin 2 years ago | 9 points | 3 comments