Impressum/Kontaktparent nodes: implemented functions
↑ First
testAplFirst
| a table result |
"http://www.microapl.co.uk/apl_help/ch_020_020_550.htm"
"data aplFirst"
"aplFirst selects the first item of its argument. When the argument is an empty array, first returns the prototype of the array."
self assert: (1 asApl) = (4 aplInterval aplReshape:#(2 2)) aplFirst.
a := (Array with:'A.S.FREEMAN' with:35 with:15000) asApl.
self assert: #(3) asApl = a aplShape.
"First item of A is a text vector"
self assert: 'A.S.FREEMAN' asApl = a aplFirst.
self assert:#(11) asApl = a aplFirst aplShape.
table := (Array with:(4 aplInterval aplReshape:#(2 2)) with:(5 aplInterval) with:('TEXT') with:('EVEN MORE TEXT')) asApl aplReshape:#(2 2).
result := (4 aplInterval aplReshape:#(2 2)).
"First item is a 2 by 2 numeric matrix"
self assert: result = table aplFirst.
self assert: #(2 2) asApl = table aplFirst aplShape.