4 ms·
If I have some apples on a table and pick single apple up, I don’t have zero apples in my hand. I think that’s why numbering doesn’t start at zero.
by wmeredith 3y ago
If I have some apples on a table and pick single apple up, I don’t have zero apples in my hand. I think that’s why numbering doesn’t start at zero.
- threatofrain 3y agoHmm but this example only makes me think about how 0 is useful. Otherwise I wouldn't be able to describe your hand prior to picking up the apple.
- KnobbleMcKnees 3y agoYou're describing counting, not numbering. Like how an array with a count of 1 has one item that is numbered by it's index, 0.
- CharlieDigital 3y agoAs a counterpoint to that, wouldn't it be kinda nice if an array index equaled the array length and index 0 was equivalent to an empty array. Think of a basket of apples. If you take the zeroth apple (empty basket), you have no apples. If you take the first apple, you have 1 apple and now the basket is empty again (0). One also wouldn't have to do [length - 1] to access the last index; it would naturally be [length].
- jxf 3y agoBut how many apples do you have just prior to the scenario starting?
- Aaargh20318 3y agoCounting starts at 1, indexing starts at 0.
- ajuc 3y agobefore picking up apple table = {apple0, apple1, apple2, apple3}; //length == 4 hand = {}; //length == 0 after table = {apple0, apple1, apple2}; length == 3 hand = {apple3}; //length == 1 You count apples in hand by looking at how many items there are, not by what indexes they have.