Impressum/Kontaktparent nodes: implemented functions

Take on Axis

testAplTakeOnAxis
| mat result table |
"http://www.microapl.co.uk/apl_help/ch_020_020_560.htm"

"Take used with axis"
"data aplTake:selector onAxis:axes"

"aplTake:onAxis: will select only from the axes specified. Any axis not specified by the axis operator remains unchanged. Each successive element of the left argument indicates how many items to take from the corresponding axis within the axis specification (and from which end)."

mat := 12 aplInterval aplReshape:#(3 4).
result := 8 aplInterval aplReshape:#(2 4).

"Take the first 2 members of the first dimension, the rows, and leave the number of columns unchanged"
self assert: result = (mat aplTake:2 onAxis:1).

result := #(1 2 3 5 6 7 9 10 11) aplReshape:#(3 3).
"First 3 columns, the second dimension"
self assert: result = (mat aplTake:3 onAxis:2).


"Overtake will follow the same rules as for take (see above)."
table := #(1 $A 2 $B 3 4) aplReshape:#(2 3).

result :=#(1 $A 2 $B 3 4 0 0 0) aplReshape:#(3 3).
"New row uses array prototype"
self assert: result = (table aplTake:3 onAxis:1).

result := #(1 $A 2 0 $B 3 4 $ ) aplReshape:#(2 4).
"Prototype of row 2 is the blank character"
self assert: result = (table aplTake:4 onAxis:2).