- Code: Select all
...any of which are not substantially longer or more difficult to code.
Agreed.
My thinking is as follows:
1. Indexing requires positive integers.
2. The semi-colon imparts meaning to which plane the indexing applies. For a 2-D array, if the index follows the semi-colon, it applies on the y- or vertical- axis
Therefore if the index is negative, it is not conforming to the above. The interpreter can take that to mean it needs to do something else.
a[;¯3] simply means the last three columns; hence the suggestion.
Rotating the array and selecting the first column does not quite work for arrays with rank higher than 2 when a single column is selected.
- Code: Select all
a←4 3 5⍴⍳1000
a[;;5]
5 10 15
20 25 30
35 40 45
50 55 60
1↑[3](⌽a)
5
10
15
20
25
30
35
40
45
50
55
60
It does when multiple columns are selected as long as you remember to rotate the result
- Code: Select all
a[;;3 4 5]
3 4 5
8 9 10
13 14 15
18 19 20
23 24 25
28 29 30
33 34 35
38 39 40
43 44 45
48 49 50
53 54 55
58 59 60
⌽3↑[3](⌽a)
3 4 5
8 9 10
13 14 15
18 19 20
23 24 25
28 29 30
33 34 35
38 39 40
43 44 45
48 49 50
53 54 55
58 59 60
I think what I suggested is a more intuitive syntax (if it were to work)
- Code: Select all
a[;;¯3]