3 ms·
Funny, just a few hours ago I asked myself the related question "Should indices start with 0 or 1?" (not for the first time). I pretty much switch my opinion as
by auggierose 4y ago
Funny, just a few hours ago I asked myself the related question "Should indices start with 0 or 1?" (not for the first time). I pretty much switch my opinion as many times as I think about it.
Here is a nice discussion on stackoverflow https://cseducators.stackexchange.com/questions/5023/why-do-we-count-starting-from-zero https://cseducators.stackexchange.com/questions/5023/why-do-...
The first answer nicely retells the dijkstra argument: integer ranges should be described using half open intervals, and [n, m) is nicer than (n, m]. Furthermore, [0, n) is nicer than [1, n+1), and that's that.
The second answer makes the observation that there is a difference between indexing and counting, and that even in daily life often the first element is indexed by 0.
Still, I rather like indexing the first element of a sequence with 1.