News for hackers. Stuff that matters.
Re:Why do arrays start at 0? by kazinator on Wednesday August 24, 2022 @01:19PM (#32582643)
What do you do for a living, and why are they paying you not to understand this?
Re:Why do arrays start at 0? by atwood22 on Wednesday August 24, 2022 @02:28PM (#32583711)
Do you know the definition of countable? A set S is countable if there is a one-to-one mapping from S to N where N is the natural numbers. Do you know that 0 is not a member of the natural numbers? We literally start counting at 1 by definition of countable.
Re:Why do arrays start at 0? by lupire on Wednesday August 24, 2022 @03:36PM (#32584652)
Nope.

Is the empty set countable? (Yes.)

Dictionary:

nat·u·ral num·bers

  the positive integers (whole numbers) 1, 2, 3, etc., and sometimes zero as well

Countable: https://en.wikipedia.org/wiki/Countable_set

Set theory:

https://en.wikipedia.org/wiki/Ordinal_number

Re:Why do arrays start at 0? by atwood22 on Wednesday August 24, 2022 @04:05PM (#32585046)
From your own link on countable sets:

> Equivalently, a set S is countable if there exists an injective function f : S → N from S to N; it simply means that every element in S corresponds to a different element in N.

Defining N is usually done via a successor set, on which case 0 makes no sense to include.

Re:Why do arrays start at 0? by lupire on Wednesday August 24, 2022 @07:05PM (#32587038)
A successor set is the set of successors of... 0 or 1, depending on what you are doing.
Re:Why do arrays start at 0? by kazinator on Wednesday August 24, 2022 @05:20PM (#32585918)
An empty set is countable; it has an empty mapping to the natural numbers. Its cardinality is zero.
Re:Why do arrays start at 0? by lupire on Wednesday August 24, 2022 @07:10PM (#32587096)
And its ordinalitiy is also 0.

Standard construction of ordinals is that each ordinal is the set of all its predecessors. (0 has no predecessors , hence 0 is the empty set.) (And so finite ordinals have the same ordinaliity as cardinality).

Re:Why do arrays start at 0? by pwdisswordfish9 on Thursday August 25, 2022 @07:59AM (#32592517)
Show me a mathematical text where ‘ordinality’ is defined.
Re:Why do arrays start at 0? by samatman on Wednesday August 24, 2022 @08:42PM (#32587863)
Are you a time traveller from the late 17th century?
Re:Why do arrays start at 0? by bmacho on Wednesday August 24, 2022 @02:45PM (#32583950)
Can't they just .. disagree?

Birthdays are clearly 1 indexed, the first birthday is indexed with 1, and not with 0.

Re:Why do arrays start at 0? by ziml77 on Wednesday August 24, 2022 @03:35PM (#32584647)
They day you're born is birthday number 0
Re:Why do arrays start at 0? by bmacho on Wednesday August 24, 2022 @05:25PM (#32585985)
Exactly.

Birthday[0] gives you an out of range exception, since there is no birthday called 0th. Birthdays are [first,second,..] indexed from 1: brithday[1] = first, birthday[2] = second, and so on. That's what indexing a series from 1 means.