User:Devon McCormick/MinimalBeginningJ

From J Wiki
Jump to navigation Jump to search

Minimal J for Beginners

One of the most difficult problems facing a beginner wanting to learn J is the overwhelming number of language primitives. Someone completely unfamiliar with the language might think that a language whose vocabulary fits on a single long page would not present such a problem. However, at least one beginner - see the comments here - has expressed bewilderment at where to start when attempting to learn the myriad of basic J operations.

Based on the suggestions from this discussion, here is a reduced instruction set of some of the most useful and commonly-used J verbs, based on my own experience.

Basic J

In the NuVoc vocabulary list, where an entry shows a pair of words or phrases separated by a raised dot (•), we are (usually) showing both the monadic (single argument on the right) and dyadic (arguments on both sides of symbol) uses for the symbol in the adjacent colored box:

Basics Examples (paste into J)
=. Is (local assignment) =: Is (global assignment) loc=. 1 2 GLO=: 'foo'
_ Negative Sign • Infinity NB. Comment _3 = -3 NB. negative vs. negate
'string' Character string '' NB. Empty vector 'Hello, World!'
Arrays
$ Shape Of • Reshape # Tally • Copy 2 2 4 $ 1 2 11 22 1 2 3 # 1 2 3
, Ravel • Append ; Raze / Link , 2 2$99 23 ; 'skidoo'
{. Take }. Drop 3 {. 'foot' 2 }. 1 2 3 4
/ Insert • Table i. Integers • Index of + / 1 10 100 i. 10 'foo' i. 'o'
Math
+ Conjugate • Plus * Signum • Times 2 + 3 30 3 30 * 2
- Negate • Subtract % Reciprocal • Divide 1 10 - 5 6 2 3 5 % 3 4 6
^ Exponential • Power ^. Natural Log • Log 2 ^ i.17 2 10 ^. 4 100  ^. 2.71828
<. Floor • Minimum >. Ceiling • Maximum 2 3 4 <. 99 1 2  >. 1.1 0.5 1.9

We may extend this minimal subset here.