Index Of
From NARS2000
Dyadic iota (L⍳R) is extended to allow 1<⍴⍴L, returning a nested array of shape ⍴R whose items are each integer vectors of length ⍴⍴R, suitable for use as indices to L.
For example, in origin-1
M←2 3⍴'abcdef'
M⍳'af'
1 1 2 3
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
∇