rslt ← indices (axis ##.squad) array ⍝ IBM APL2 Indexing function.
Supplied by Steve Mansour, this operator simulates IBM APL2's Indexing function:
Reference: APL2 at a Glance, Appendix F: APL2 Release Functions - Indexing
pp. 395-397
Indices: A (possibly) nested vector, each item containing the indices of the
corresponding axis in the operand.
Axis: A list of axes corresponding to the items of the left argument (indices)
If the operand is the empty vector, all axes are included.
Array: Any array whose rank is greater than 0.
NB: Dyalog V11 implements squad indexing ⌷ as a primitive function.
Examples:
⎕IO←1
B←2 3 4⍴⍳24
(2 1)1(3 1)('' squad)B ⍝ Equivalent to B[2 1;1;3 1]
15 13
3 1
(1 1 1)(2 1 3)('' squad)¨⊂B
1 15
(⊂(2 1)1(3 1))('' squad)¨B(10×B)(100×B)
15 13 150 130 1500 1300
3 1 30 10 300 100
V←'ABCDEFGHI'
3 ('' squad)V ⍝ Equilvalent to V[3]
C
(⊂3 4) ('' squad)V ⍝ Equivalent to V[3 4]
CD
(2 1)(3 1) (1 3 squad) B ⍝ Equivalent to B[2 1;;1 3]
15 13
19 17
23 21
3 1
7 5
11 9
⎕io ⎕ML←0 3 ⍝ Check origin 0 and ML>0.
2 ('' squad) 3 4 5
5
1 (0 squad) 'ABCD'
B
NAMES←⊃'STEVE' 'PAUL' 'GEORGE'
1(0 squad) NAMES ⍝ Equivalent to NAMES[1;]
PAUL
0(1 squad) NAMES ⍝ Equivalent to NAMES[;0]
SPG
1 2('' squad) NAMES ⍝ Equivalent to NAMES[1;2]
U
2(1 2)(0 1 squad) NAMES ⍝ Equivalent to NAMES[2;1 2]
EO
See also: from merge
Back to: contents
Back to: Dyalog APL
Trouble seeing APL font?