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

Reply via email to