>>
<<
Usr
Pri
JfC
LJ
Phr
Dic
Rel
Voc
!:
Help
Primer
Fork
A train of three verbs is a fork and is evaluated as follows:
(f g h) y evaluates as (f y) g (h y)
x (f g h) y evaluates as (x f y) g (x h y)
A simple example of a fork is the sequence of three verbs +/ % # . The / adverb takes its left argument + and returns a verb, so there is a sequence of three verbs. Let's examine the use of this fork monadically.
(f g h) y evaluates as (f y) g (h y)
(+/ % #) y evaluates as (+/ y) % (# y)
This can be read as: sum over the argument divided by the count of the argument. This is the definition of the mean or average.
(+/ % #) 5 9 12
8.66667
(+/ % #) i.9
4
You can now define mean as a fork with +/ % # .
mean =. +/ % #
mean i.9
4
>>
<<
Usr
Pri
JfC
LJ
Phr
Dic
Rel
Voc
!:
Help
Primer