4 ms·
1-indexed arrays are pretty common in languages targeted at scientific/mathematical usage. Also the case in R, Fortran, Matlab, and Mathematica, among others.
by _delirium 13y ago
1-indexed arrays are pretty common in languages targeted at scientific/mathematical usage. Also the case in R, Fortran, Matlab, and Mathematica, among others.
- moron4hire 13y ago"This is the way we've always done it" is not a convincing argument.
- steveklabnik 13y ago... for or against 1 or 0 indexed arrays? ;)
- gfodor 13y agoExcept that's not the argument.
- AimHere 13y agoThe argument is more along the lines of 'the users for these systems use 1-based subscripts in their technical literature so we'll make conversion from formula-in-physics-paper to running code easier by having the corresponding data structure match the user's expectation.' 0-based arrays are easier for computer folks who occasionally have to implement the code that translates 'a[i]' into a memory access. 1-based is easier for physicists and mathematicians who were subscripting variables before there were computer implementations to worry about and had a pile of literature already written using that idiom. It's just a clash of conventions.
- dubya 13y agoTo be fair to Fortran, you can easily choose whatever indexing you want. 1 is just the default.
- CatMtKing 13y agoThat's even worse!