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

Vocabulary

The J Dictionary is the J reference book and is your ultimate, authoritative source of information on J. The sooner you become familiar with using it the better, and a good way to start is by looking up the primitives that have been introduced so far.

The back cover of the J Dictionary (or last page, depending on the edition) is called the vocabulary. It is a concise listing of all the primitives and gives a page reference to the detailed definition. Learning how to use the vocabulary is your key to learning how to read and write J.

If you don't have a printed copy of the J Dictionary, or if you prefer it, you can use the online version instead. Press F1 to show the vocabulary and click a primitive to jump to the entry. If you press F1 while holding down Ctrl you get context sensitive help. If the caret is at a +, pressing Ctrl+F1 will jump to the + entry.

In the vocabulary take a look at the row for + , which is the fifth row. The first entry in this row contains: + Conjugate o Plus. The word + is a verb and its monad is called conjugate, and its dyad is called plus. The dyad + is plus as defined in arithmetic.

The monad + is interesting. In math, the conjugate of a complex number is the number with the same real part and an imaginary part of opposite sign. On real numbers the conjugate has no effect and the result is the argument, and on complex numbers it changes the sign of the imaginary part. J supports complex numbers just as directly as integers or real numbers. A complex number is indicated by a j separating the real and imaginary parts.

   int =. 23
   + int
23

 
   float =. 23.5
   + float
23.5

   imagine =. 2j3	NB. 2 real part, 3 imaginary part
   + imagine	NB. change sign of imaginary part
2j_3

Many primitives support complex numbers and the J Dictionary must document this, which means there is a bit of extra complexity in some of the descriptions. If you need complex numbers in your application this is fantastic. But if you are a beginner and are not concerned with complex numbers, then you have to know enough to be able to ignore these bits and not get distracted or confused.

The page number of the definition for + is in the rightmost column of the + row. Turn to that page now.

The header line of the page gives the monad name Conjugate on the left side, and the dyad name Plus on the right. The formal name of the primitive + is near the center. The 0 0 0 to the right of the + will be explained later.

Below this header are two boxes (or columns, in the online documentation). The left box has the monad definition and the right box has the dyad definition. The page then continues with general discussion and examples.

The J Dictionary is a concise, rigorous, and complete reference suitable for the most experienced users. This can make it difficult for beginners who don't know what to expect. For example, in the general discussion and examples for + there is considerable discussion of complex numbers and not a single example of just adding a couple of integers. Great for the experienced user who would be insulted if told how to add integers, but a bit of a reading challenge for the real beginner. You have to learn how to tune out, for now, the bits that are too advanced or are not relevant to your current interest, and concentrate on the parts that are.

Go back to the vocabulary page and take a look at the +. entry (fifth row, second entry) which contains: +. Real/Imaginary o GCD (Or). There is a lot of information here, and again much of it is not relevant at this early stage. Let's look at the definition. The page number in the hardcopy manual is for the first entry in the row and the other entries are on the following pages.

Glance at the left box for the monad definition and notice that it is for complex numbers. File it for future reference, but give it a pass for now.

The dyad case in the header is described as: GCD (Or). This gives two informal names, GCD and Or, and indicates it can be used in two different ways. The dyad definition is in the right box. Note that GCD stands for greatest common divisor (which should at least ring a bell of math memories). Further on in the definition you will find that if the arguments are boolean then the +. is the logical or function. The GCD is a useful extension of the domain of the or function to non-boolean arguments. This extension of the domain of primitives is common in J. For now, it is interesting to note that +. has this larger domain, but it is also easy to limit it to boolean arguments.

   0 +. 0	NB. 0 or 0
0

   0 +. 1
1

   1 +. 0
1

   1 +. 1
1

The vocabulary page entry for +: contains: Double o Not-Or. The definition page, which follows the + and +. definition pages, gives quite simple definitions for both the monad and dyad.

The monadic case is called double and does just what you'd expect.

   +:  3
6

The dyadic case is the logical negation of the or of the arguments.

Again, for both +. and +: much of the general discussion and examples are perhaps beyond your capabilities right now. But the key is to know how to navigate and to get the information that is relevant.

After the row for ? there are additional rows for primitives that are spelled with names that are inflected with a dot or colon.


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