4 ms·
> 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 conclusio
by 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...
- zAy0LfpBZLC8mAC 10y ago> It's like arguing which is a more precise way to measure temperature, in fahrenheit or celsius scale... Nah, bad analogy. Let me suggest a better version: It's like arguing about whether degree Fahrenheit or Kelvin is a more useful default unit to use for physics calculations. What do you think? It's not just a number that's used to start enumerating from, it's a set of numbers used to calculate with as well, and array indexing, as I mentioned, is an additive operation, and thus using a set of indices that's not a group, for lack of an identity element, is as sensible as doing most of your physics calculations in degree Fahrenheit. > 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. Exactly. And you realize that that is the first ordinal number, right? "First" means "the one without a predecessor", and the empty set, also represented as a zero in that context, is the element without a predecessor, and as such the first ordinal number of that construction. Now, what is your point? > We use null for that in programming. We use null to represent the first ordinal number? What kind of weird languages are you using?!? > 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... First of all, it seems like you are utterly confused about the relevance of von Neumann's constructions of ordinal numbers to how to index arrays. There is none. It's simply an exercise in finding an isomorphism between sets and "normal" numbers. Also, no, I don't ignore the empty array. An empty array has no positions, therefore, there is no ordinal number that could refer to a position in an empty array. If you have an index pointing into an empty array, you are doing something wrong. You cannot point to the fifth element in a four-element array, you cannot point to the second element in a one-element array, and you cannot even point to the first element in a zero-element array. If you want to be able to have a data structure that can represent an index into an array, or alternatively the absence of an index (for whatever reason--one reason might be because the array is empty), that's your problem, not the problem of the index type. Why should we reserve perfectly useful values of data types to represent stuff that's logically separate from the type? How about we reserve the value "2" in floating point values for cases where you want to store the word "honey" as a floating point value? That's just crazy. You can possibly use such sentinel values in your software for performance reasons or whatever, but limiting sensible use by the general public because you want to mix concerns?!? The third element of the sub-array starting at the second element of an array is which element of the base array? With zero-based indices, that is a perfectly normal additive operation: 1 + 2 = 3 --the element is to be found at index 3. With one-based indices, you resurrect all the crazyness of algebra and arithmetics before the zero was invented, just because you want to use the zero for something else: 2 + 3 = 5 ... and the index is 4, obviously!