Impressum/Kontaktparent nodes: implemented functions

⌈ Greater of

testAplGreaterOf
|a b r t e |
"http://www.microapl.co.uk/apl_help/ch_020_020_100.htm"

"dataA aplGreaterOf: dataB"

"Finds the larger of two numbers. Each number in dataA is compared with the corresponding number in dataB. The result is the larger number from each comparison. "

self assert: 91 asApl = (87 asApl aplGreaterOf: 91).
self assert: 91 asApl = (91 asApl aplGreaterOf: 87).
self assert: 91 asApl = (87 asApl aplGreaterOf: 91 asApl).
self assert: 91 asApl = (91 asApl aplGreaterOf: 87 asApl).

"The negative number nearer 0 is considered the greater"
self assert: -5 asApl = (-5 asApl aplGreaterOf: -9).
self assert: -5 asApl = (-9 asApl aplGreaterOf: -5).
self assert: -5 asApl = (-5 asApl aplGreaterOf: -9 asApl).
self assert: -5 asApl = (-9 asApl aplGreaterOf: -5 asApl).

"Each number in a vector is compared with the corresponding number in a vector of equal size"
a:= #(20 7 40) asApl.
b:= #(91 3 41) asApl.
r:= #(91 7 41) asApl.
self assert: r = (a aplGreaterOf:b).
self assert: r = (b aplGreaterOf:a).

"The aplReduce: operator used with #aplGreaterOf: to select the biggest in each row. See the entry for aplReduce:"
t := #(62.8 3.0 -2.9 9.1 7.3 0.01 ) aplReshape: #(2 3).
r := #( 62.8 9.1) asApl.
e := t aplReduce:#aplGreaterOf:.
self assert: r = e.