In APL the old-style subscripting works like this:
A is 2 3 4 5 reshape iota 120 (makes a 2x3x4x5 array of the integers to 120)
A[;1 3;;2 4]
returns a 2x2x4x3 array with with Ai2j(1,3,or5) missing.
Derive does substantially the same thing with proper use of parentheses. The above would be written
(A sub sub [1,3]) sub sub sub sub [2,4]
However Derive's subscripting has an inconsistency -
APL
A[2;1 3;1 3;2 4 5]
62 64 65
72 74 75
102 104 105
112 114 115
Derive
A sub 2 sub sub [1,3] sub sub sub [1,3] sub sub sub sub [2,4]
results in nonsense, but
A sub 2 sub [1,3] sub sub [1,3] sub sub sub [2,4]
yields the correct result:
⎡⎡ 62 64 65 ⎤ ,⎡ 102 104 105 ⎤⎤
⎣⎣ 72 74 75 ⎦ ,⎣ 112 114 115 ⎦⎦
Why?
Apparenly Derive treats the first two subscripts as if they always apply to matrices - an array of dimension N is really an array of vectors of dimension N-1.
Another example:
APL
A[;2;1 3;2 4 5]
22 24 25
32 34 35
82 84 85
92 94 95
Derive
A sub sub 2 sub sub [1,3] sub sub sub [2,4,5]
⎡⎡ 22 24 25 ⎤ ⎡ 82 84 85 ⎤⎤
⎣⎣ 32 34 35 ⎦ , ⎣ 92 94 95 ⎦⎦
But notice
APL
A[;;1 3;2 4 5]
2 4 5
12 14 15
22 24 25
32 34 35
42 44 45
52 54 55
62 64 65
72 74 75
82 84 85
92 94 95
102 104 105
112 114 115
Derive
A sub sub sub [1,3] sub sub sub sub [2,4,5]
⎡ ⎡ 2 4 5 ⎤ ⎡ 22 24 25 ⎤ ⎡ 42 44 45 ⎤ ⎤
⎢ ⎣ 12 14 15 ⎦ ⎣ 32 34 35 ⎦ ⎣ 52 54 55 ⎦ ⎥
⎢ ⎥
⎢ ⎡ 62 64 65 ⎤ ⎡ 82 84 85 ⎤ ⎡ 102 104 105 ⎤ ⎥
⎣ ⎣ 72 74 75 ⎦ ⎣ 92 94 95 ⎦ ⎣ 112 114 115 ⎦ ⎦
This is annoying but internally consistent.
-drl
Stay up-to-date with your friends through the Windows Live™ Spaces friends list. Check it out!