Array Lookup: Difference between revisions
From NARS2000
Jump to navigationJump to search
No edit summary |
Sudleyplace (talk | contribs) No edit summary |
||
Line 31: | Line 31: | ||
<p>For example, in origin-1</p> | <p>For example, in origin-1</p> | ||
<apll> | <apll><pre> | ||
Dina | ⎕←L←6 4⍴'DinaDickJohnJaneSue Mary | ||
Dick | Dina | ||
John | Dick | ||
Jane | John | ||
Sue | Jane | ||
Mary | Sue | ||
Mary | |||
Jane | ⎕←R←3 4⍴'JaneBob Sue '<br /> | ||
Bob | Jane | ||
Sue | Bob | ||
Sue | |||
4 7 5</apll> | L⍸R | ||
4 7 5</pre></apll> | |||
<p>This function was suggested by the language designers of Dyalog APL.</p> | <p>This function was suggested by the language designers of Dyalog APL.</p> |
Latest revision as of 15:16, 15 April 2018
|
||||
L and R are arbitrary arrays. | ||||
Z is an array of rank 0⌈1+(⍴⍴R)-⍴⍴L and shape (1-⍴⍴L)↓⍴R. | ||||
For matrices, the result is equivalent to (⊂[2] L)⍳⊂[2] R (lookup the rows of one array in another) 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. | ||||
This function is sensitive to both ⎕IO and ⎕CT. |
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
This function was suggested by the language designers of Dyalog APL.