>>  <<  Ndx  Usr  Pri  Phr  Dic  Rel  Voc  !:  wd  Help  Primer

Rank conjunction "

The primitive " (double-quote, not two quotes) is the rank conjunction. Conjunctions haven't been introduced yet and there is more detail in a later section. For now, just think of a conjunction as similar to a dyad verb in that it takes a left and right argument and has a result. The particular use of " of interest here is when the left argument is a verb and the right argument is a noun. Yes, conjunctions can take verb arguments, as well as noun, whereas a verb can take only noun arguments.

In the section on names there was an example where you directly defined a name as a verb.

   plus =. +

This style of definition is more direct than the type you used to define centigrade. It is called tacit definition and is dealt with in more detail in a later section. The name plus is defined as the primitive + and thus has the same rank as + of 0 0 0 .

The rank conjunction produces a new verb from its left argument with the rank information from its right argument.

   plus000 =. + " 0 0 0

The right argument for " is the rank information for the primitive + that is given in the J Dictionary (look up + in the vocabulary, turn to the definition page, and note the rank information in the heading). The first 0 is the rank of the monad argument. The second and third 0's are respectively the rank of the dyad left and right arguments.

Since plus000 is + with same ranks as the primitive + it should behave just as does + or plus . You can verify this with a few experiments borrowed from the previous section on agreement.

   a =. i. 2 3
   a plus000 a
0 2  4
6 8 10

   a plus000 1 2 3
�length error
�   a   plus000 1 2 3

The length error occurs because the arguments do not agree as per the previous section. The left frame is 2 3 and the right frame 3, and 3 is not a prefix of 2 3; there are extra cells from the left argument without corresponding cells from the right argument.

However, it seems reasonable to want to add the list 1 2 3 to each list in the left argument. You know what you want it to do. Visually:

0 1 2   +   1 2 3      gives   1 3 5
3 4 5       ...                4 6 8

You want a variation of + that adds lists from its left argument to lists from its right. You can do that by changing the arguments to the " conjunction to indicate that the dyad left and right ranks are lists.

   plus011 =. + " 0 1 1
   a plus011 1 2 3
1 3 5
4 6 8

 
   1 2 3 plus011 a
1 3 5
4 6 8

In practice you wouldn't bother to give a name to such a specific application of + and you would instead use the expression directly.

   1 2 3 +" 0 1 1 a
1 3 5
4 6 8

Since + is applied dyadically and both ranks are 1, you can use the shorter form of +"1 which uses 1 for the rank of all arguments.

   1 2 3 +"1 a
1 3 5
4 6 8

In this case, the left frame is empty with a cell shape of 3 and the right frame is 2 with a cell shape of 3. Empty is a prefix of 2, and so the frames agree.

There is one thing you have to be aware of.

   a +"1 1 2 3
�length error
�   a    +"1 1 2 3

The problem is that J doesn't know that you want the first 1 to be the argument to " and the second 1 to be part of the constant 1 2 3. What happens is that the constant 1 1 2 3 is used as the right argument of " and since " is defined to allow only arguments of 1 2 or 3 numbers, there is a length error. You need to let J know that the 1 belongs to the " and that the 1 2 3 is a constant.

   a (+"1) 1 2 3
1 3 5
4 6 8

   a +"1 (1 2 3)
1 3 5
4 6 8

>>  <<  Ndx  Usr  Pri  Phr  Dic  Rel  Voc  !:  wd  Help  Primer