For example, if we have a verb that multiplies all the arguments of a list:
PROD =: */PROD 2 3 4 5120
we can make a composition verb with the following verb (which decrements the argument):
DEC =: -1:
The composition is written thus:
COMP =: PROD@:DEC
COMP 1
0
COMP 2 3 4
6
COMP 2 0.5
_0.5
COMP 3 1.5
1
Here the composition verb, COMP, multiplies the decremented elements of the list. i.e. COMP 2 3 4 will multiply 1*2*3 = 6.
Generally if f and g are two monadic verbs and y is the argument then
f@:g y = f(g y)It should be noted that the composiiton @: is not associative. i.e.
f@:(g@:h) does not equal (f@:g)@:h for verbs f,g,h.Obviously g@:f usually doesn't equal f@:g. For example, using our above verbs:
COMP2 =: DEC@:PROD
COMP2 1
0
COMP2 2 3 4
23
COMP2 2 0.5
0
COMP2 3 1.5
3.5
Obviously COMP and COMP2 are completely different verbs.
Next we'll look at composition of dyadic verbs.