🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5338

Re: 0-based/1-based arrays

#5338
From: J Bradfield
Date: Sun, 20 Mar 1988 17:44
41 lines
2744 bytes
In article <25739@cca.CCA.COM> g-rh@CCA.CCA.COM.UUCP (Richard Harter) writes:

>An ordinal number is a specification of the position of an element in an
>ordered sequence.  If I have a sequence, <a,b,c> a is the first element,
>b is the second, and c is the third.  An ordinal number is related to
>a cardinal number since the ordinal of the last element of the sequence
>is the 'same' as the cardinal measuring the size of the sequence, considered
>as a set.  I.e., in a sequence with n elements the last one is the n'th.
>Ordinals start with 1, and go 1,2,3,...  
>
>In arithmetic the numbers are primitive elements with arithmetic operations
>defined on them.  Zero is the identity element, i.e. the number such that
>for all x, x+0 = x.  It turns out that there is a direct correspondence
>between the non-negative integers of arithmetic and the cardinal numbers.
>
>And so on.  Sorry to be pedantic, but what a number is and what it means
>depends on what you are talking about and what you mean.

If we're going to be pedantic and mathematical, let's at least get it right.
The ordinals start at zero: ordinals are defined as equivalence classes of
well-ordered sets, and the smallest ordinal is the order type of the empty
set, to wit, zero. Cardinals are defined either as equivalence classes of
ordinals (all those having the same size), or as the smallest ordinal in
the equivalence class. For example, the smallest infinite cardinal,
aleph-0, is the size of the sequence <0,1,2,...> -- but it's also the size
of the sequence <0,1,2,...,0,1,2,...>, which has twice the length of the 
first one. See any book on elementary set theory for more about ordinals
and cardinals.
There is a one-one corrspondence between *finite* cardinals and the 
non-negative integers; but there's a one-one correspondence between
finite ordinals and finite cardinals: it's only in the infinite case
that it is necessary to distinguish carefully.

All this is rather irrelevant to arrays; set theory is not necessarily
a good guide for language designers!

Personally, I use whichever base seems more appropriate for the task
in hand---which is why I object to languages that won't let me start
arrays at zero.

Julian Bradfield.
Technical Details
Message-ID: <1106@its63b.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!ukc!its63b!jcb
References: <25739@cca.CCA.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!mcvax!ukc!its63b!jcb
From: jcb@its63b.ed.ac.uk (J Bradfield)
Newsgroups: comp.lang.misc
Subject: Re: 0-based/1-based arrays
Message-ID: <1106@its63b.ed.ac.uk>
Date: 20 Mar 88 17:44:41 GMT
References: <25739@cca.CCA.COM>
Reply-To: jcb@lfcs.ed.ac.uk (J Bradfield)
Followup-To: comp.lang.misc
Organization: Lab. for Foundations of Computer Science, Univ. Edinburgh, UK
Lines: 41
Keywords: arrays one zero ordinals
Summary: What ordinals really are