B. Verbs

Monads and Dyads. Verbs have two definitions,
one for the monadic case (one argument),
and one for the dyadic case (two arguments).
The dyadic definition applies if the verb is preceded by
a suitable left argument, that is, any noun that is not itself
an argument of a conjunction; otherwise the monadic definition applies.

The monadic case of a verb is also called a monad,
and we speak of the monad % used in the
phrase %4 ,
and of the dyad % used in 3%4 .
Either or both may have empty domains.

Ranks of Verbs. The notion of verb rank is closely
related to that of noun rank: a verb of rank k applies
to each of the k-cells of its argument.
For example (using the array b from
Section A):

   ,"2 b                         ,"_1 b
abcdefghijkl                  abcdefghijkl
mnopqrstuvwx                  mnopqrstuvwx

Since the verb ravel (denoted by ,)
applies to its entire argument, its rank is said to be unbounded.
The rank conjunction " used in the phrase ,"2
produces a related verb of rank 2 that ravels each of the 2-cells
to produce a result of shape 2 by 12.

The shape of a result is the frame (relative to the cells to which
the verb applies) catenated with the shape produced by applying
the verb to the individual cells.

Commonly these individual shapes agree, but if not,
they are first brought to a common rank
by introducing leading unit axes to any of lower rank,
and are then brought to a common shape by
padding with an appropriate fill element: space for a character
array, 0 for a numeric array, and a boxed empty list
for a boxed array. For example:

   i."0 s=: 2 3 4                >'I';'was';'here'
0 1 0 0                       I
0 1 2 0                       was
0 1 2 3                       here

The dyadic case of a verb has two ranks, governing the
left and right arguments. For example:

   p=: 'abc'
   q=: 3 5$'wake read lamp '
   p,"0 1 q

Finally, each verb has three intrinsic ranks:
monadic, left, and right. The definition of any verb need specify
only its behaviour on cells of the intrinsic ranks, and
the extension to arguments of higher rank occurs systematically.
The ranks of a verb merely place upper limits on the ranks of
the cells to which it applies; its domain may include
arguments of lower rank. For example, Matrix Inverse (%.)
has monadic rank 2, but treats the case of a vector as
a one-column matrix.

Agreement. In the phrase p v q,
the arguments of v must agree in the sense that one
frame must be a prefix of the other, as in p,"0 1 q above,
and in the following examples:

   p ,"1 1 q                     3 4 5 * i. 3 4
abcwake                        0  3  6  9
abcread                       16 20 24 28
abclamp                       40 45 50 55
   (i.3 4) * 3 4 5
 0  3  6  9
16 20 24 28
40 45 50 55

If a frame contains 0, the verb is applied
to a cell of fills. For example:

   ($ #"2 i. 1 0 3 4);($ 2 3 %"1 i. 0 2)
|1 0|0 2|
   ($ $"2 i. 1 0 3 4);($ 2 3 %/"1 i. 0 4)
|1 0 2|0 2 4|