jeff at ccvcorp.com
Wed Nov 21 20:53:17 CET 2001
Glenn R Fulford wrote:
> "Huaiyu Zhu" <huaiyu at gauss.almadan.ibm.com> wrote in message
> news:slrn9vlstk.4ut.huaiyu at gauss.almadan.ibm.com...
> > Mathematicians do not really care about whether the index starts with zero
> > or one. They just need some index, which could start from 42 if you want.
> > But when they do care, such as defining the axioms of natural numbers,
> > seem to prefer starting from zero as well
> On the other hand, most work with matricies has indexing starting from 1.
> Noone uses matrix indices (0,0). Note that MatLab does it's indexing from 1,
> and I thought that nupy is thought of as a replacement for matlab? The whole
> idea of using software to do mathematics is to have a language which feels
> natural to translate the maths into the program.
> . I initially learned
> > programming in Fortran, but when I learned C later it felt much more
> > natural. I guess some other people might feel the same way too.
> Not me!
For a good explanation of why zero-based indexing is a *very* good idea in
programming, read this lovely explanation by (the much missed) Alex Martelli:
(all one line, in case that gets broken...)
It typically does take a little bit to adjust to, but once that adjustment is
made, off-by-one errors are *much* less likely than with 1-based indexing.
More information about the Python-list