[Jprogramming] index origin 0

Roger Hui rhui000 at shaw.ca
Wed Jul 28 08:07:53 HKT 2010


> How does APL interpret negative index for either index origin?

No APL I know of implements negative indexing.
It would be a consistent extension because it'd
replace an error with a result.
----- Original Message -----
From: bill lam <bbill.lam at gmail.com>
Date: Tuesday, July 27, 2010 16:57
Subject: Re: [Jprogramming] index origin 0
To: programming at jsoftware.com
> Втр, 27 Июл 2010, Alex Rufon писал(а):
> > +-+-+-------------------------------------+
> > |4|:|NB. indices-of-elements (IO=1) from y|
> > | | |(_1 + x) { 
> y                         |
> > +-+-+-------------------------------------+
>> This equation is interesting. So when counting from the end.
> the last item is A[0], the second last item is A[-1]
> ie. index origin 0
>> whereas for J the last item is A[-1], second last is A[-2]
> ie, index origin 1
>> To be more correct for human domain so that always use index 
> origin 1
> when counting both from the beginning and from the end, it can be
> improved as
>> if. 0=x do. assert. 0
> elseif. 0<x do. (_1+x){y
> elseif. do. x{y
> end.
>> How does APL interpret negative index for either index origin?


More information about the Programming mailing list

AltStyle によって変換されたページ (->オリジナル) /