3 ms·
Hmm, I don't know directly about arrays. But for indexing into a linked list 0-based just seems to make the mest sense---if you interpret the index as "how man
by eru 10y ago
Hmm, I don't know directly about arrays. But for indexing into a linked list 0-based just seems to make the mest sense---if you interpret the index as "how many pointer do I have to chase?".
And giving arrays the same treatment then seems reasonable for consistency?
I always saw 0-based indices as offsets. Ie like their C interpretation, where a[i] is defined to be the same as * (a+i), not the less natural *(a+i+1).
But I can see some points for 1 based indexing, too.
(Anecdote from university: the math faculty had a building that started numbering the ground floor as -1. Perhaps just to one up (or is that one down?) the computer scientists who always feel smug about counting from 0.)
- FireFly 10y agoThat anecdote reminds me of the classic solution to the zero-versus-one-indexing fights in the Lua community: clearly the solution is to compromise! :) http://lua-users.org/lists/lua-l/2006-05/msg00281.html http://lua-users.org/lists/lua-l/2006-05/msg00281.html