NuVoc - The New Vocabulary

From J Wiki
Jump to navigation Jump to search

<=   =>

NuVoc (menu Help|Vocabulary) is the up to date J reference 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.

While in the JQt IDE, press F1 to show NuVoc and click a primitive to jump to the entry. If you press F1 while holding down Ctrl (Cmd for Mac) you get context sensitive help. If the caret is at a +, pressing Ctrl+F1 will jump to the + entry.

In NuVoc take a look at the 6th row which contains + . The first entry in this row contains: + 0 Conjugate . Plus 0 0. The word + is a verb. Its monad is called Conjugate, and its dyad is called 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
   float =. 23.5
   + float
   imagine =. 2j3    NB. 2 real part, 3 imaginary part
   + imagine	     NB. change sign of imaginary part

Many primitives support complex numbers and NuVoc 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.

Let's look at the Plus entry in the wiki. You can access by clicking on the link 'Plus'. This will take you to middle of the page describing +. The top half of the wiki page is information describing Conjugate. The header line for Plus shows that it is a dyadic verb with arguments x and y. Below is a link to Rank 0 0 with a link to Why is this important. You will learn about this soon enough

Below this is a brief description of +. The page then continues with general discussion and examples.

Return to the NuVoc and take a look at the +. entry in the column to the right of + which contains: +. Real/Imaginary for monadic and GCD (Or) for dyadic. Let's look at the definition.

The top half of the reference page covers the Real/Imaginary use of +. and lower half covers GCD (Or).

The dyadic case is described as: GCD (Or) with two informal names, GCD and Or, indicating that it can be used in two different ways. 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 +. 1
   1 +. 0
   1 +. 1

Moving over one more column in NuVoc we see the vocabulary page entry for +: contains: Double for monadic and Not-Or for the dyadic case. The definition gives quite simple definitions for both the monad and dyad.

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

   +:  3

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

Again, some of the general discussion and examples in NuVoc 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 ? and ?. there are additional rows for primitives that are spelled with names that are inflected with a dot or colon.
Below the primitive tables are a table of Ancillary Pages which explain some of the concepts of J. It may be worth having a look at some of these after you have completed this Primer, as they give greater detail of some of the concepts you will have seen.

<=   =>

Primer Index               Hover to reveal titles   -   Click to access   -   Current page is highlighted
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
45 46 47 48
50 51 52 53 54 55 56 57
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
97 98 99 100 101 102 103 104 105 106