I notice almost all defenses of 1-based indexing are purely based on arbitrary cultural factors or historical conventions, e.g. “that’s how it’s done in math”, rather than logical arguments.
I notice almost all defenses of 1-based indexing are purely based on arbitrary cultural factors or historical conventions, e.g. “that’s how it’s done in math”, rather than logical arguments.
You have lived zero full years and are in the first year of your life. In most (but not all) countries the former is considered "your age".
That's consistent with both zero-based and one-based indexing. Both agree on cardinal numbers (an array [1, 2] has length 2), just not on ordinal numbers (whether the 1 in that array is the "first" or "zeroth" element).
> I notice almost all defenses of 1-based indexing are purely based on arbitrary cultural factors or historical conventions, e.g. “that’s how it’s done in math”, rather than logical arguments.
I think it's largely a matter of taste in either direction. But, I'd raise this challenge:
arr = ['A', 'B', 'C', 'D', 'E', 'F']
slice = arr[3:1:-1]
print(slice)
If you're unfamiliar with Python (zero-based, half-open ranges exclusive of end), that's taking a slice from index 3 to index 1, backwards (step -1). How quickly can you intuit what it'll print?Personally I feel like I have to go through a few steps of reasoning to reach the right answer - even despite having almost exclusively used languages with 0-based indexing. If Python were instead to use MatLab-style indexing (one-based, inclusive ranges), I could immediately say ['C', 'B', 'A'].
I agree that it should be ['C', 'B'] - the way that Python handles negative `step` values is wrong.
I do. I think it only makes sense for ranges to be inclusive at the lower end and exclusive at the higher end. A slice with a negative step `-n` should contain the same elements as the same slice as with step `n`, just reversed.
I think whenever people say "zeroth" they speak in jest and doubt that there is any disagreement on the fact that the element without predecessor (nowadays in programming most often assigned index 0) is the first element.
You used "first" in that sense naturally just in the sentence before without the slightest notion of ambiguity.
You have lived zero full years and are in the first year of your life.
What people wrongly get riled up with is the fact that ordinal (first) is not in sync with the cardinal (index 0), but it rarely is anyways. If you go to an administrative office and pull your number 5357 no one assumes that there are 5356 people in the queue before them. Your are still the 5th or 10th in line, even if your index is 5357.
"Zeroth" sounds silly because English has generally settled on one-based indexing, and so typically you'd convert to one-based indexing when speaking out loud or writing something other than code (`users[3]` is the "4th user").
Maybe you could argue that the words "first"/"second", as just some letters/sounds, are not inherently one-based? But I feel that gets a bit dubious from "third" onwards where the connection to numbers is obvious, and with the ordinals frequently spelled as 1st/2nd/etc.
But, if you want (and if I'm understanding what you mean), you could replace my statement with: "whether the '1' in that array is the index-1 or index-0 element" - purpose was just to distinguish between ordinals and cardinals, in response to a comment that seemingly implied the cardinality of an empty collection would be 1 with one-based-indexing.
Consider the following from the Irish Constitution:
> 12.4.1° Gach saoránach ag a bhfuil cúig bliana tríochad slán, is intofa chun oifig an Uachtaráin é.
and the official translation to English:
> 12.4.1° Every citizen who has reached his thirty-fifth year of age is eligible for election to the office of President.
For those unfortunate few who do not understand Irish, that version says "Every citizen who is at least thirty-five years old", whereas the translation should in principle (arguably) allow a thirty-four-year-old.
Luckily the Irish version takes precedence legally. A constitutional amendment which would have lowered the minimum age to 21 and resolved the discrepancy was inexplicably rejected by the electorate in 2015.
Typically 3 months shy of 1 year, so about 0.75.
For human cultural purposes, you are 0 days old at the time and date recorded for your birth. It goes on your birth certificate. If you find a culture that celebrates conceptiondays and issues conception certificates, let me know.
While that is the norm, there both are and have been cultures where you are 1 when you are born (as in you are living your first year of life).
You know some cultures don’t even celebrate birthdays, right? It’s not even uncommon for people to not know their date of birth. Even my own grandmother, born in Chicago in the 1920s, didn’t even know exactly what year she was born in.
No culture I know of tracks the date of your conception as a measure of your age. If they measure it at all, the starting point is your birth.
You are zero days old on the day of your birth. Even if those cultures think you are "in the first year of your birth" for days 0-365 of your existence, they would accept that 1 day after your birth, you are 1 day old, not 9 months old.
If it helps: you have one whole array element only if one year has passed
What are you trying to do: do you want to know where each element starts, or do you want to measure the total sum/accumulated amount?