Impressum/Kontaktparent nodes: implemented functions

⍳ Index of

testAplIndexOf
| days search |
"http://www.microapl.co.uk/apl_help/ch_020_020_160.htm"

"data aplIndexOf: search"

"aplIndexOf: finds whether the items in the search argument occur in the data argument (which must be a vector) and if so in what positions. For each element in the search argument a number is returned showing its position in the data argument. If an element is not found in the data argument (or if the arguments are of different types), a number one greater than the position of the last element in the data argument is returned. The shape of the result is the same as that of the search argument."

"9 is in position 3"

self assert: 3 asApl = (#(2 5 9 14 20) asApl aplIndexOf: 9).

"12 isn't in the data argument, so a number 1 greater than the number of data elements"
self assert: 6 asApl = (#(2 5 9 14 20) asApl aplIndexOf: 12).

"S occurs in position 4"
self assert: 4 asApl = ('GORSUCH' asApl aplIndexOf: $S).


"The characters 'CARP' are in positions 3 1 18 and 16"
self assert: #(3 1 18 16) asApl = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' asApl aplIndexOf: 'CARP').


"The 27 in the result indicates characters not found in the 26-character data argument. In this case the 'space' character."
self assert: #(16 15 18 11 27 16 9 5) asApl = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' asApl aplIndexOf: 'PORK PIE').

days := (Array with:'MON' with:'TUES' with:'WED') asApl.

"days is a 3 element vector"
self assert: #(3) asApl = days aplShape.

search := (Array with:'MON' with:'THURS') asApl.

"'MON' found in first position, 'THURS' is not found"
self assert:#(1 4) asApl = (days aplIndexOf: search).