2 ms·
In math when we write a sum, we say "sum from i = 1 to n", not "sum from i = 0 to n-1". Zero-based indexing of arrays makes sense in a language like C where ar
by czep 8y ago
In math when we write a sum, we say "sum from i = 1 to n", not "sum from i = 0 to n-1".
Zero-based indexing of arrays makes sense in a language like C where arrays are just pointers and offsets are determined with arithmetic on pointer addresses in memory. This is why we are trained to write code like "for (i = 0; i < n; i++)". But in Julia where one of the stated purposes is to be able to write code that looks like formulae, it is far more natural to use one-based indexing.
- deleted 8y ago[deleted]
- ModernMech 8y agoSure I get that. MATLAB and FORTRAN also use 1 based indexing, so that's nothing new. People have been arguing about that since 1950 :P I just didn't understand the context of the post.