>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Primer

Verb rank

A verb has a rank that determines how it applies to its arguments. A monad of rank k applies to the k-cells of its argument. A dyad of left rank kl and right rank kr applies to the kl-cells of its left argument and the kr-cells of its right argument. Verb rank is a powerful tool that controls the way a verb applies to arrays.

The ranks of a primitive verb are given in the J Dictionary definition. For example, look up the definition of + . The rank information follows the word in the header. For + this is 0 0 0. The monad rank is 0 which indicates the monad + applies to the atoms. The dyad ranks are 0 for the left argument (indicating it applies to the atoms, or 0-cells), and 0 for the right argument (again indicating it applies to the atoms in the right argument).

Let's see how this works when adding two tables.
   a =. i. 2 3
   b =. 6 + a
   a
0 1 2
3 4 5
   b
6  7  8
9 10 11
   a + b
 6  8 10
12 14 16
The dyad + has left rank 0. This means it applies to the atoms of its left argument. Similarly the right rank is 0 and it applies to the atoms of its right argument. The verb takes an atom from its left argument, an atom from its right argument, and adds them together to create a partial result. It does this for each atom from the left and right argument and creates an appropriate number of partial results, which are then assembled into the result frame to create the final result.

In the example above the verb + has a left rank of 0. This means the left argument is treated as a 2 3 frame of atoms. Similarly, a right rank of 0 means that the right argument is treated as a 2 3 frame of atoms.

The frame of the result is determined by the frames of the arguments, and so its frame is also 2 3 and each cell is the result of adding an atom from the left argument with an atom from the right argument.

>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Primer