Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^4: why the array index has to start at 0??

by hdb (Monsignor)
on Oct 13, 2013 at 10:02 UTC ( #1058051=note: print w/replies, xml ) Need Help??


in reply to Re^3: why the array index has to start at 0??
in thread why the array index has to start at 0??

From Wikipedia Natural_number as well:

There is no universal agreement about whether to include zero in the set of natural numbers: some define the natural numbers to be the positive integers {1, 2, 3, ...}, while for others the term designates the non-negative integers {0, 1, 2, 3, ...}. The former definition is the traditional one, with the latter definition having first appeared in the 19th century.
  • Comment on Re^4: why the array index has to start at 0??

Replies are listed 'Best First'.
Re^5: why the array index has to start at 0??
by lidden (Curate) on Oct 13, 2013 at 11:21 UTC
    To me it seems math people usually exclude zero while computer people include zero.
      > To me it seems math people usually exclude zero

      nope.

      Math people changed their mind, but for historical reasons there is some confusion.

      Natural numbers are defined by successively adding 1 and zero is the neutral element of addition.

      It's much easier to operate on sets with neutral element included!

      Most integer operations (at least in Perl) can return 0.

      Thats the meta-argument why Moritz's answer makes perfect sense. This way combinations of integer functions always include another neutral element as possible result.

      For instance otherwise adding the sum of the first index of two arrays would be 2 (the second element) instead of 0 (again the first)

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      1) the concept of natural numbers was older than group theory

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1058051]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2023-12-03 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (20 votes). Check out past polls.

    Notices?