Oh. Error handling for negative index was never an issue for the simple fact 
that we work with SQL/database tables. I believe this was the trump card used 
against me (I was pro-0 IO since it would be natural when working with J). 
Table columns and rows always start with 1. :) Or as database programmers would 
always say 1st row or 1st column ...

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of bill lam
Sent: Wednesday, July 28, 2010 7:56 AM
To: [email protected]
Subject: Re: [Jprogramming] index origin 0

Втр, 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?


--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to