🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #5223

Re: The Joy of Zero-based Arrays

#5223
From: Richard Harter
Date: Sun, 06 Mar 1988 19:30
33 lines
1782 bytes
Most of the fuss and confusion comes about because there are three
different kinds of 'numbers' involved: cardinals, ordinals, and displacement
measures.

A cardinal number is the measure of the size, e.g. this array has five
elements.

An ordinal number is the count sequence, e.g. this is the 1st element,
... this is the 5'th element.

A displacement measure is the distance between an element and the base,
e.g. this element is displaced four elements from the base.

Ordinals match cardinals, e.g. if a sequence has five elements, the last
ordinal corresponds to the cardinal number of the sequence.  There are
fundamental reasons for not mucking with the definition of ordinal, which
I won't go into.

Displacement measures are more useful than ordinals in programming.
The fundamental reason is that names in programming specify addresses,
i.e a[i] is the item located at address 'a[i]'.  Regardless of the language
array basing index, 'i' is used to determine a displacement from the
array address.

The fencepost problem is intrinsic -- in a sequence containing 'n' items
the displacement between the first and the last element in the sequence
is 'n-1'.  This fact is not altered by the array basing scheme used.

-- 

In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
	Richard Harter, SMDS  Inc.
Technical Details
Message-ID: <25349@cca.CCA.COM>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!cca!g-rh
References: <1012@PT.CS.CMU.EDU> <17419@think.UUCP> <213@sdti.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!cca!g-rh
From: g-rh@cca.CCA.COM (Richard Harter)
Newsgroups: comp.lang.misc
Subject: Re: The Joy of Zero-based Arrays
Message-ID: <25349@cca.CCA.COM>
Date: 6 Mar 88 19:30:09 GMT
References: <1012@PT.CS.CMU.EDU> <17419@think.UUCP> <213@sdti.UUCP>
Reply-To: g-rh@CCA.CCA.COM.UUCP (Richard Harter)
Organization: Computer Corp. of America, Cambridge, MA
Lines: 33