5 ms·
Zero-based indexing is always wrong; an ordered collection of things does not have a zeroth thing. Sometimes you have a data structure called an "array", which
by juped 4y ago
Zero-based indexing is always wrong; an ordered collection of things does not have a zeroth thing.
Sometimes you have a data structure called an "array", which means "a bunch of things that are the same size next to each other in memory". You can store the address of the whole array as the address of its first element, and offset into it by an offset; clearly, the offset of the first element is zero, but it's not the "zeroth" element.
And finally, sometimes you have cargo cult behavior by people who think that the way offsets into arrays work is because "numbering starts at zero in computers!" or some similarly wrong rationalization. This is when you get stupid things like (nth 0 list) in a lisp.
- dalmo3 4y agoAn ordered collection of events in time usually starts at t(0).
- ryanisnan 4y agoI hate to break it to you but natural spoken language is not a fixed concept, words can have many meanings and interpretations, and those meanings and interpretations can mean different things to different people at different times. Because you predominantly think of indexing as the first definition as shown here[1], does not mean everyone else does. Be careful when using absolutes, especially when talking about languages. [1] - https://www.merriam-webster.com/dictionary/index https://www.merriam-webster.com/dictionary/index
- Schroedingersat 4y agoAn ordered collection of things starts no things from the beginning. A journey starts 0 metres from the origin. If you count the number of _ you are along your journey and start with 1, then at the second metre you are at the 101st centimetre. When someone says how many dragons have you slain? Just as you leave and haven't heard of any dragons yet, you don't say "I'm slaying my first dragon now" Every construction of the natural numbers I have seen starts with 0. The first hour of the day has passed when the clock strikes one. The hour preceding that is the same day. English calls it 12 because it was invented before we had a firm grasp of zero and english is inconsistent. 24 hour clocks call it 00. 1 based indexing can be correct, but 1 based ordered discrete sets map incredibly poorly to any ordered set with a different number of elements (such as the reals). Additionally dealing with ranges is less easy to make consistent. 0 based indexing is always correct.
- kazinator 4y agoSome guitars have a zeroth fret; an actual fret at the nut.