3 ms·
I agree with Dijkstra on using one-side open, one-side closed boundaries to denote a range of integers. (C.S. way) 0 <= a < N (Math way) 0 < b <= N As he sa
by benlorenzetti 10y ago
I agree with Dijkstra on using one-side open, one-side closed boundaries to denote a range of integers.
(C.S. way) 0 <= a < N
(Math way) 0 < b <= N
As he says, both ways have the property that
"upper bound - lower bound = Number of elements", both can represent an empty set "lower bound = upper bound", and both make partitioning easy "(0 <= a < M)U(M <= a < N)".
However I disagree that including the lower bound way is preferable to the starting at 1, math way. Math is the older science and children are still taught to count in this way.
As many of the benefits of one way or the other are mostly just network effects (i.e. in math subscripts typically start at 1 or in C, ints and structs are pointed to by their lowest char), we should have used the notation of the older science.