4 ms·
> I have to offer a counter view to this. Using letters of the alphabet as an analogy isn't accurate to me. Each letter we accept as an element... so a true ana
by zAy0LfpBZLC8mAC 10y ago
> I have to offer a counter view to this. Using letters of the alphabet as an analogy isn't accurate to me. Each letter we accept as an element... so a true analogy would be to put a Space as the first character of the alphabet, to indicate the absence of a letter.
So, you would say that "A" is not the first element of the alphabet or that "0" is not the first cardinal number?
> Zero indicates the absence of a value in our numbering system.
You are utterly confused. If I have an account balance of zero, that indicates an absence of a value? How is zero mathematically any different then +1000 or -1000 that justifies making it a special case?
> If I have a single apple, I have 1 Apple, not 0 Apples. Thus if I have 1 element in an Array I have element[1], not element[0].
You are mixing up ordinal and cardinal numbers.
> It is more natural for us to use numbers not by their cardinal position in a set, but by their inferred value... because they represent quantities.
There is no such thing as a "cardinal position", positions are ordinal, cardinality describes sizes.
> I am one of those who feels the confusion around zero bounded indexes leads to countless issues because it is counter-intuitive to how we use numbers in real life.
Nope, what leads to problems is that people don't understand the difference between cardinal and ordinal numbers. You cannot fix that by changing the first index, all that causes is a shift to different bugs. Including stuff like equating zero with the absence of a value.
- thomnific 10y agoI agree with you and also with the person you replied to. But more generally -- is it fair to say that cardinality describes size as opposed to quantity? If you go with the quantity concept instead then 1-based numbering makes sense and agrees with ordinary usage. (Disclaimer: I used to hate 1-based indexing, for reasons similar to what you are saying, but I'm brainwashed by R these days and now rather like it.)
- zAy0LfpBZLC8mAC 10y ago> is it fair to say that cardinality describes size as opposed to quantity? Nope, size is equivalent to quantity in this context. But ordinals describe position in an order as opposed to size/quantity. If you want to connect them mathematically, you would usually map a scale to a quantity measure, where the first unit position on the scale is the zero-position, the second unit position is the one-position, and so on--so, a quantity of size three units reaches from the position 0 on the scale to the position 3 on the scale. > (Disclaimer: I used to hate 1-based indexing, for reasons similar to what you are saying, but I'm brainwashed by R these days and now rather like it.) Well, it doesn't matter unless you have to to arithmetic with the indices, you might as well label them with letters from the alphabet, so if you don't need that, it's simply a matter of getting used to it. But in general-purpose programming languages, array indices are often computed, and 1-based indexing is as sensible there are having an integer type that doesn't have a zero. It's not that you cannot work with it, but it makes things unnecessarily complicated.
- ivanhoe 10y ago> How is zero mathematically any different then +1000 or -1000 that justifies making it a special case? Zero is actually always a special case in math, specially in algebra, the only number where division by it is not defined. > Nope, what leads to problems is that people don't understand the difference between cardinal and ordinal numbers. Actually, by Von Neumann definition of ordinals, ordinal 0 represents an empty set, thus it's equivalent of null, not single element set. So strictly mathematically speaking for non-empty sets we should use ordinals starting at 1. But using zero-based indices is just a matter of convention, so lets not make a big philosophy out of it...
- zAy0LfpBZLC8mAC 10y ago> Zero is actually always a special case in math, specially in algebra, the only number where division by it is not defined. And what does any of this have to do with division? > Actually, by Von Neumann definition of ordinals, ordinal 0 represents an empty set, thus it's equivalent of null, not single element set. So strictly mathematically speaking for non-empty sets we should use ordinals starting at 1. So, strictly mathematically speaking, we should use "2 apples" to describe an apple within another apple, where both of those apples also contain nothing? I'm sorry, but this just makes no sense whatsoever. What relevance does von Neumann's construction of the natural numbers have to this question? Especially so, given that the empty set, aka "0", is the first(!) von Neumann ordinal. We should use 1-based ordinals because von Neumann constructed 0-based ordinals, maybe? > But using zero-based indices is just a matter of convention, so lets not make a big philosophy out of it... No, it's not. You yourself stated that the algebraic/arithmetic behaviour of 0 is quite different from that of 1, so how do you suddenly come to the conclusion that it's merely a matter of convention?
- ivanhoe 10y ago> No, it's not. You yourself stated that the algebraic/arithmetic behaviour of 0 is quite different from that of 1, so how do you suddenly come to the conclusion that it's merely a matter of convention? Because in programming it is, it's just a number chosen by some languages to start enumerating from because it makes things easier in some real-life cases. In pascal you could set the arbitrary start and end index and it worked just as well. It's like arguing which is a more precise way to measure temperature, in fahrenheit or celsius scale... > What relevance does von Neumann's construction of the natural numbers have to this question? Especially so, given that the empty set, aka "0", is the first(!) von Neumann ordinal. We should use 1-based ordinals because von Neumann constructed 0-based ordinals, maybe? You talked of ordinal numbers, so I cited one of the definitions of ordinal numbers, the one from the set theory. The similar reasoning applies for other definitions as well. Ordinal number zero is always the ordinal of an empty set. We use null for that in programming. So the next one is a single element set and it has ordinal 1. So how from this you conclude that index 0 is "the correct way" to count non-empty sets? You completely ignore the empty array that way...