News for hackers. Stuff that matters.
Re:GNU Octave by ogogmad on Saturday January 21, 2023 @12:12PM (#34467921)
What you've said isn't surprising.

The problem isn't whether 0 or 1 are "right" or not, it's the inconsistency. It makes transcribing something from a textbook harder, because the indexing logic in a textbook algorithm can get quite intricate. It's even worse if they use slices like M[i:j,m:n].

Indexing from 1 is the standard in many areas, going back many decades. SWEs have adopted a different convention.

Re:GNU Octave by ethbr0 on Saturday January 21, 2023 @12:22PM (#34468033)
(Obligatory) There are only 2 hard problems in computer science: cache invalidation, naming things, and off-by-one errors
Re:GNU Octave by tmtvl on Saturday January 21, 2023 @01:20PM (#34468699)
may You concurrency forgotten have.
Re:GNU Octave by ethbr0 on Saturday January 21, 2023 @03:44PM (#34470306)
It just printed out in your comment a few hours after I thought I invoked it.
Re:GNU Octave by enriquto on Saturday January 21, 2023 @12:18PM (#34467995)
but this depends a lot on the particular formula. For example, if you use discrete Furier transforms, all formulas are natural with 0-indexing, but weird with 1-indexing. In general, when the indices of an array are to be interpreted as modulo N, you want them to be 0, 1, ..., N-1

It is inevitable to have to use both conventions if you do varied math stuff. Thus, you will never be happy.

Re:GNU Octave by ogogmad on Saturday January 21, 2023 @12:37PM (#34468204)
The pragmatic solution for transcribing is probably to make some functions `array_index` and `array_slice` that automatically convert between the two conventions. I think Julia offers another way: It lets you choose between them.
Re:GNU Octave by Beldin on Saturday January 21, 2023 @01:20PM (#34468697)
I prefer OPTION BASE {0, 1} :)