Re:Lua vs Ruby benchmarks (similarly "high-level" languages,...
by ralph on Saturday February 07, 2009 @12:46PM
(#471291)
The last element of an array is foo[-1] regardless of it's length. :-) And try implementing a circular buffer using an array of N elements with 1-based indexing and then 0-based. Sorry in advance for the loss of hair due to the former.
In many cases I don't care about specifying boundary conditions at all; I will just use something along the lines of
or even just a map or fold or some other iteration technique where I'm not explicitly specifying boundary conditions. If I'm implementing a heap or some other data structure which uses calculations to interact with an array I will be double-checking my math anyway because I don't trust myself to get it right the first time, 0-based indexing or not ;)