Index Of: Difference between revisions
From NARS2000
Jump to navigationJump to search
Sudleyplace (talk | contribs) No edit summary |
Sudleyplace (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
<table border="0" cellpadding="5" cellspacing="0" summary=""> | <table border="0" cellpadding="5" cellspacing="0" summary=""> | ||
<tr> | <tr> | ||
<td><apll>Z←L⍳R</apll></td> | <td valign="top"><apll>Z←L⍳R</apll></td> | ||
<td></td> | <td></td> | ||
<td></td> | <td></td> |
Revision as of 20:22, 7 May 2008
|
||||
L is an array of rank > 1. | ||||
R is an arbitrary array. | ||||
Z is a nested array of shape ⍴R whose items are each integer vectors of length ⍴⍴L, suitable for use as indices to L, except for where the item in R is not found in L, in which case the corresponding item in Z is ⎕IO+⍴L. | ||||
This feature extends dyadic iota to rank > 1 left arguments. |
For example, in origin-1
M←2 3⍴'abcdef'
M⍳'afg'
1 1 2 3 3 4
M[M⍳'af']
af
This extension is implemented via an internal magic function:
∇ Z←L #DydIota R;⎕IO;O
[1] O←⎕IO ⋄ ⎕IO←0
[2] Z←⊂[0] O+(1+⍴L)⊤(¯1↓,(1+⍴L)↑L)⍳R
∇