Array Lookup

From NARS2000
Revision as of 04:46, 26 May 2013 by WikiSysop (talk | contribs) (Created page with "<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> <tr> <td> <table border="0" cellpadding="5" cellspacing="0" summary=""> <tr> <td val...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
Z←L⍸R returns a simple integer vector identical to (⊂⍤(¯1+⍴⍴L) L)⍳⊂⍤(¯1+⍴⍴L) R.
L and R are arbitrary arrays.
Z is an integer vector of length 1↑⍴R.
For matrices, the result is equivalent to (⊂[2] L)⍳⊂[2] R which encapsulates a common idiom in one symbol.
For higher rank arrays, the arguments are enclosed to become vectors of subarrays and then the usual lookup produces the final result.


For example, in origin-1

      ⎕←L←6 4⍴'DinaDickJohnJaneSue Mary'
Dina
Dick
John
Jane
Sue
Mary
      ⎕←R←3 4⍴'JaneBob Sue '
Jane
Bob
Sue
      L⍸R
4 7 5