[Jprogramming] index origin 0
Bo Jacoby
bojacoby at yahoo.dk
Mon Jul 26 00:43:16 HKT 2010
I agree with Ken. No big deal. It is nice trying to protect the user from making mistakes, but often unsuccessful. Removing the restriction in the definition of { does not change 1{'abc'. J is marvelous anyway!
:)
- Bo
--- Den søn 25/7/10 skrev Roger Hui <rhui000 at shaw.ca>:
Fra: Roger Hui <rhui000 at shaw.ca>
Emne: Re: [Jprogramming] index origin 0
Til: "Programming forum" <programming at jsoftware.com>
Dato: søndag 25. juli 2010 01.17
> I consider the restriction to be bad design. I would prefer:
>> If x is an integer, then x{y selects item n|x from y .
So under this definition, is 1{'abc' a or b?
Ken had actually wanted unrestricted indices
(with origin 0), but we convinced him that
it would be a bad idea. If the user executes
2e9{'abc' you are doing him/her a big favor
by signaling an error, rather than have execution
continue with some garbage result which then
blows up many lines later.
----- Original Message -----
From: Bo Jacoby <bojacoby at yahoo.dk>
Date: Saturday, July 24, 2010 14:07
Subject: Re: [Jprogramming] index origin 0
To: Programming forum <programming at jsoftware.com>
> When counting to three you say one two three, not zero one two.
>>> Cardinal numbers: (0,1,2,...) measure finite sets, and ordinal
> numbers: (first, second, third ...), identify elements in finite
> sets. There is no such thing as zeroth.
>> The second millenium ended on december 31'th year 2000, not on
> december 31'th 1999. The year numbers are ordinal numbers: One-
> origin indexing.
>> When a car has run 2000 (kilometers or miles) the odometer
> shifts from 1999 to 2000. The distance is a cardinal number:
> Zero-origin indexing.
>>> A zero-origin index should not be understood as an ordinal
> number, but rather as how may elements have passed before we
> reach the element we need.
>> The J-vocabulary says about { :
>> If x is an integer in the range from -n=: #y
> to n-1 , then x{y selects item n|x
> from y .
>> I consider the restriction to be bad design. I would prefer:
>> If x is an integer, then x{y selects item n|x
> from y .
>> In that way you do not need to know the index origin. A 10-
> element vector can be indexed either from 0 through 9 or from 1
> through 10, as you prefer. Element no 10 is the same as element
> no 0.
>> - Bo
>> --- Den lør 24/7/10 skrev June Kim (김창준) <juneaftn at gmail.com>:
>> Fra: June Kim (김창준) <juneaftn at gmail.com>
> Emne: Re: [Jprogramming] index origin 0
> Til: "Programming forum" <programming at jsoftware.com>
> Dato: lørdag 24. juli 2010 19.59
>> On Sat, Jul 24, 2010 at 10:16 PM, Roger Hui <rhui000 at shaw.ca>
> wrote:
> > I have been asked by some APL colleagues about
> > index origin 0 in J. The question is, does the choice
> > of a fixed value of 0 for index origin a hindrance to
> > your work? The question is specifically addressed
> > to "ordinary domain experts", people with no
> > software engineering in their background and are not
> > professional mathematicians.
> >
> > In case you did not know, in APL there is a choice
> > known as the index origin, controlled by the variable
> > quad-io, of counting from 1 instead of from 0, affecting
> > the left argument of { and the result of i. , among other things.
> > I will say no more than this to avoid biasing your answers.
> >
>> I am okay with index origin 0. I see the reasons, like Dijkstra
> did[0], but
> some of my friends, whom I would call ordinary domain experts
> without much
> experience in programming, felt uncomfortable about it, at least
> in the
> beginning. However, when I tell them the index means "interval
> points"(likea cursor), they made less mistakes.
>> You may see some debates on this[1].
>> [0] E.W. Dijkstra Archive: Why numbering should start at zero
> (EWD 831)
> http://userweb.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
>> [1] Why numbering should start at 0 | Lambda the Ultimate
> http://lambda-the-ultimate.org/node/1950
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list