Terence -
the vocabulary page for "i.", while technically correct in stipulating that
the left rank of this verb is infinite, is perhaps misleading in that it
looks
up only items from the left argument so, in a sense, really only treats the
left argument as a vector. The examples on the definition page should make
this a little clearer.
However, the problem you're attempting to solve, looking up a scalar
in a higher-dimensional array, comes up frequently. I think of it this way:
(,i. 2 3) i. 4
4
2 3 #: 4 NB. 4 as a base (2,3) number
1 1 NB. gives index into original array.
(<2 3 #: 4) { i. 2 3
4
ixmd=: 4 : '($x)#:y i.~ ,x' NB. Index multi-dimensionally
(i. 2 3) ixmd 4
1 1
Regards,
Devon
On 5/4/07, Terrence Brannon <[EMAIL PROTECTED]> wrote:
Ok, I'm wondering how I might find the number 4 in a rank-2 array
using dyadic i. Below are my failed naive attempts after reading the
section in "Learning J" which went over Selecting.
(i. 2 3) i. 4
|rank error
| (i.2 3) i.4
(i. 2 3) i. (3 4 5)
1
(i. 2 3) i."1 4
|syntax error
| (i.2 3)i."1 4
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm