In the
J programming language, a
hook is the special name given to a
composite verb made by
concatenating two
verbs. The general
format for a
monadic hook follows (
h is
monadic, while
g is
dyadic, and
v is some
noun):
(g h) v is identical to v g (h v)
For example:
- (+ 0.1&*) v is equivalent to v + ((0.1&*)v) (which is the same as v + 0.1*v due to the use of the bond conjunction). One interpretation of this result is the total amount paid for v if there is a 10% tax.
- (= {:) v is equivalent to v = ({: v), which compares each element of v with its head, leaving a boolean vector.
There are also dyadic hooks, in which another noun is present:
u (g h) v is identical to u g (h y)
Again, an example:
- u (; %:) v is equivalent to u ; (%: v), which is the join of u to the square root of v.
A hook is a special case of a fork, which is the more general building block of trains in J. More information on extended chaining of J verbs can be found at train.