I prefer an error message. It usually means I messed up (again). If I want
it to wrap as you suggest it is easy to do.
   (5|i.7){i.5
0 1 2 3 4 0 1
   7$i.5
0 1 2 3 4 0 1

An example as to where I would want an error. I would not want it to select
'a'. I want an error.

   'c'(]{~i.~)'abcde'
c
   'f'(]{~i.~)'abcde'
|index error
|   'f'    (]{~i.~)'abcde'

On Sat, Mar 7, 2009 at 11:06 AM, Bo Jacoby <[email protected]> wrote:

>
> To the very honored designers of J.
>
> The vocabulary states that: "If x is an integer in the range from -n=: #y
> to n-1 , then x{y selects item n|x from y ."
>
> Now my question is the following: What is the purpose of the restriction
>  "in the range from -n=: #y to n-1"? Why not simply define: "If x is an
> integer, then x{y selects item (#y)|x from y ." ?
>
> This suggests a generalization of the present definition. Arrays are then
> addressed cyclically, and the distinction between zero-origin indexing and
> one-origin indexing disappears.
>
> For example:
>
>   (i. 7) { i. 5    NB. Nobody prefers an error message to a result.
> |index error
> |   (i.7)    {i.5
>
>   (i. 7) { i. 5    NB. My suggestion is the result (here faked).
> 0 1 2 3 4 0 1
>
>   (_5+i. 7) { i. 5 NB. it works in an arbitrarily restricted interval
> 0 1 2 3 4 0 1
>
>
>
> Thank you.
>
> Bo Jacoby
>
>
>
>
>      Trænger du til at se det store billede? Kelkoo giver dig gode tilbud
> på LCD TV! Se her http://dk.yahoo.com/r/pat/lcd
> ----------------------------------------------------------------------
> 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