Skip to content

A Dictionary of J

Vector 7:2, page 99

language design

Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 99

Doubtful transcription

The dictionary is set small in two columns with many side-by-side examples; their layout here is approximate, and the bold marking in the parsing table (Table 2) is read as nearly as the print allows. Check examples against the page.

The ISI Dictionary of J

J is a dialect of APL, a formal imperative language. Because it is imperative, a sentence in APL may also be called an instruction, and may be executed to produce a result. Because it is formal and unambiguous it can be executed mechanically by a computer, and is therefore called a programming language, a phrase from which its name derives. Because it shares the analytic properties of mathematical notation, it is also called an analytic language.

APL originated in an attempt to provide consistent notation for the teaching and analysis of topics related to the application of computers, and developed through its use in a variety of topics, and through its implementation in computer systems. Discussions of the language may be found in The Design of APL and The Evolution of APL [1]. Reference 2 discusses a freeware implementation of the language defined here, as well as its relation to the earlier version [3], which also provides information on other dialects.

A dictionary should not be read as an introduction to a language, but should rather be consulted in conjunction with other material (such as Reference 4) that uses the language in some context of interest. On the other hand, a dictionary should be used not only to find the meanings of individual words, but should also be studied to gain an overall view of the language.

I: Alphabet and Words

The alphabet used is that of ASCII, and the words used to denote facilities in the language are spelled with either one ASCII character or with one character followed by a full stop (.) or a stop (:). Spaces between such words are permitted but not required, except that a number beginning with a decimal point must be prefaced by a space or a zero. The entire spelling scheme is shown in the Language Summary of Table 1.

Pronouns and proverbs begin with a letter of the English alphabet and continue with further letters or digits. Such a name followed by a colon is a distinguished or non-standard word that may, in a particular implementation, be used to supplement the standard words.

Quotes behave much as in English: everything between an opening quote and a closing quote is treated as a single word, except that a pair of adjacent quotes following an opening quote represents the quote character itself; 'can''t' is the five-character abbreviation of the six-character word 'cannot'.

The negative sign is denoted by _, as in _3 and _3.14. The _ alone denotes infinity, and __ denotes negative infinity. A real number may also be denoted in exponential form, as in 3.25e4 to signify 32500. A complex number is denoted by a j between two real numbers, as in _3e4j5.6. Numbers separated by spaces denote a list or vector, as in prices=. 3.12 4.6 2e3.

II: Grammar

The following sentences illustrate the six parts of speech:

   fahrenheit=. 50
   (fahrenheit-32)*5%9
10
   prices=. 3 1 4 2
   orders=. 2 0 2 1
   orders*prices
6 0 8 2
   +/orders*prices
16
   +/\1 2 3 4 5
1 3 6 10 15
   bump=. +&1
   bump prices
4 2 5 3
PARTS OF SPEECH
50 fahrenheit Nouns/Pronouns
+ - * % bump Verbs/Proverbs
/ \ Adverbs
& Conjunction
( ) Punctuation
=. Copula

Verbs act upon nouns to produce noun results; the nouns to which a particular verb apply are called its arguments. A verb may have two distinct (but usually related) meanings according to whether it is applied to one argument (to its right), or to two arguments (left and right). For example, 2%5 yields .4, and %5 yields .2.

An adverb acts upon a single noun or verb (to its left) to produce a verb. For example, +/ is a (derived) verb called plus over that sums an argument list to which it is applied, and */ yields the product of a list. A conjunction applies to two arguments (either nouns or verbs) to produce a verb.

Punctuation is provided by paired parentheses that specify the sequence of execution as in elementary algebra. The word =. behaves like the copulas "is" and "are" and is read as such, as in "area is 3 times 4" for area=. 3*4. The name area thus assigned is a pronoun and, as in English, it plays the role of a noun. Similar remarks apply to names assigned to verbs, adverbs, and conjunctions.

A. Nouns

Nouns are classified in three ways: numeric or literal; open or boxed; arrays of various ranks, called (for ranks 0, 1, and 2) atom, list, and table, or (in mathematics) scalar, vector and matrix. Numbers and literals are represented as stated in Part I.

Arrays. A single entity such as 'A' or '+' or 2.3 or _2.3j5 is called an atom. The verb denoted by a comma chains its arguments to form a list whose shape (given by the verb $) is equal to the number of atoms combined. For example:

   date=. 1,7,7,6
   $ date
4
   word=. 's','a','w'
   |. word
was
   |. date
6 7 7 1

The verb |. used above is called reverse. The phrase s $ b produces an array of shape s from the list b. For example:

   (3,4) $ date,1,8,6,7,1,9,1,7
1 7 7 6
1 8 6 7
1 9 1 7
   table=. 2 3 $ word,'bat'
   $ table
2 3
   table
saw
bat

The number of atoms in the shape of a noun is called its rank. Each position of the shape is called an axis of the array, and axes are referred to by indices 0, 1, 2, etc. For example, axis 0 of table has length 2 and axis 1 has length 3. The last k axes of an array b determine rank-k cells or k-cells of b. For example, if:

   a=. 'abcdefghijklmnopqrst'
   b=. 2 3 4 $ a,'uvwxyz'
   b
abcd
efgh
ijkl

mnop
qrst
uvwx

then the list 'abcd' is a 1-cell of b, the two 3 by 4 tables are each 2-cells of b, and the letters are each 0-cells of b.

The rest of the shape vector is called the frame of b relative to the cells of rank k. For example, if $ c is 2 3 4 5, then c has the frame 2 3 relative to the cells of rank 2, the frame 2 3 4 relative to 5-element rank-1 cells, the frame 2 3 4 5 relative to rank-0 cells (atoms), and an empty frame relative to 4-cells.

A cell of rank one less than the rank of b is called an item of b, and items play an important role in the discussion of nouns and the application of verbs to them. For example, the verb from (denoted by {) selects items from its right argument, as in:

   0{b
abcd
efgh
ijkl
   1{b
mnop
qrst
uvwx
   0{0{b
abcd
   2 1{0{b
ijkl
efgh
   1{2{0{b
j

Moreover, the verb grade (denoted by /:) provides indices to { that bring items to "lexical" or "row-major" order. For example:

   n=. 4 3 $ 3 1 4 2 7 9 3 2 0
   g=. /:n
   n
3 1 4
2 7 9
3 2 0
3 1 4
   g
1 0 3 2
   g{n
2 7 9
3 1 4
3 1 4
3 2 0

Negative numbers, as in _2-cell and _1-cell (an item), are also used to refer to cells whose corresponding frames are of the length indicated by the magnitude of the number. For example, the list abcd may be referred to either as a _2-cell or as a 1-cell of b.

Open and Boxed. The nouns discussed thus far are called open, to distinguish them from boxed nouns produced by the verb box denoted by <. The result of box is an atom, and boxed nouns are displayed in boxes. Box allows one to treat any array (such as the list of letters that represent a word) as a single entity, or atom. For example:

   w=. words=. (<'I'),(<'was')
   letters=. 'I was'
   $ letters
5
   |. letters
saw I
   $ words
2
   |. words
┌───┬─┐
│was│I│
└───┴─┘
   2 3$w,|.w
┌─┬───┬───┐
│I│was│was│
├─┼───┼───┤
│I│I  │was│
└─┴───┴───┘

B. Verbs

Monads and Dyads. Most verbs have two definitions, one for the monadic case (one argument), and one for the dyadic case (two arguments). In any sentence, the dyadic definition of a verb applies if it is preceded by a suitable left argument, that is, any noun that is not itself an argument of a conjunction; otherwise the monadic definition applies. The monadic case of a verb is also called a monad, and we speak of the monad % used in the phrase %4, and of the dyad % used in 3%4.

Ranks of verbs. The notion of verb rank is closely related to that of noun rank: a verb of rank k applies to each of the k-cells of its argument. For example (using the array b from Section A):

   ,b
abcdefghijklmnopqrstuvwx
   ,"2 b
abcdefghijkl
mnopqrstuvwx
   ,"_1 b
abcdefghijkl
mnopqrstuvwx

Since the verb ravel (denoted by ,) applies to its entire argument, its rank is said to be infinite or unbounded. The rank conjunction " used in the phrase ,"2 produces a related verb of rank 2 that ravels each of the 2-cells of b to produce a result of shape 2 by 12.

The shape of a result is the frame (relative to the cells to which the verb applies) catenated with the shape produced by applying the verb to the individual cells. Commonly these individual shapes agree, but if not, they are first brought to a common rank by adding leading unit axes to any of lower rank and are then brought to a common shape by applying the expression ms {. r to each result r, where ms is the maximum over the individual shapes. For example:

   i."0 (2 3 4)
0 1 0 0
0 1 2 0
0 1 2 3
   >'I';'was';'it'
I
was
it

The dyadic case of a verb has two ranks, governing the cell ranks of the left and right arguments. For example:

   p=. 'abc'
   q=. 3 5 $ 'wake read lamp '
   p ,"0 1 q
awake
bread
clamp

Finally, each verb has three intrinsic ranks: monadic, left, and right. The definition of any verb need therefore specify only its behaviour on cells of the specified ranks, and the extension to arguments of higher rank occurs systematically. The ranks of a verb merely place upper limits on the ranks of the cells to which it applies, and its domain may include arguments of lower rank. For example, matrix inverse (%.) has monadic rank 2, but applies to degenerate cases of vector and scalar arguments by treating them as one-column matrices.

Agreement. In the phrase p v q, the arguments of v must agree in the sense that their frames (relative to the ranks of v) must either match, or the shorter (in terms of the number of axes) must match the suffix of the longer. Formally, if the frames of p and q are a,b and b, respectively, then p v q is equivalent to p v >a$<q. For example:

   p ,"1 1 q
abcwake
abcread
abclamp

C. Adverbs and Conjunctions

Unlike verbs, adverbs and conjunctions have fixed valence; an adverb is monadic (applying to a single argument to its left), and a conjunction is dyadic.

Each argument of a conjunction may be either a noun or a verb, and it may therefore produce as may as four distinct classes of results. For example, u&v produces the composition of the verbs u and v; ^&2 produces the square by combining the power function with the right argument 2; and 2&^ produces the function 2-to-the-power. The conjunction & may therefore be referred to by different names for the different cases, or it may be referred to by the single term and (or with), which roughly covers all cases.

D. Comparatives

The comparison x=y is treated like the everyday use of equality (that is, with a reasonable relative tolerance), yielding 1 if the difference x-y falls relatively close to zero. Tolerant comparison also applies to other relations and to floor and ceiling (<. and >.); a precise definition is given in Part III under the comparative less-than-or-equal (<:). An arbitrary tolerance t can be specified by using the custom conjunction (&:), as in x =&:t y.

E. Parsing and Execution

A sentence is evaluated by executing phrases in a sequence determined by the parsing rules of the language. For example, in the sentence 10%3+2, the phrase 3+2 is evaluated first to obtain a result that is then used to divide 10. In summary, the parsing rules are:

  1. Execution proceeds from right to left, except that when a right parenthesis is encountered, the segment enclosed by it and its matching left parenthesis is executed, and its result replaces the entire segment and its enclosing parentheses.
  2. Adverbs and conjunctions are executed before verbs; the phrase ,"2-a is equivalent to (,"2)-a, not to ,"(2-a). Moreover, the left argument of an adverb or conjunction is the entire verb phrase that precedes it. For example, in the phrase a+/..*/b, the rightmost adverb / applies to the verb derived from the phrase +/..*, not to the verb *.
  3. Verbs are applied dyadically if possible. For example, a-b signifies subtraction, but a*-b signifies multiplication of a by the negative of b.
  4. Certain phrases that would be invalid under these rules are treated as idioms, as described in Section F.

One important consequence of these rules is that in an unparenthesized expression the right argument of any verb is the result of the entire phrase to the right of it. The sentence 3*p%q^|r-5 can therefore be read from left to right: the overall result is 3 times the result of the remaining phrase, which is the quotient of p and the part following the %, and so on.

Parsing proceeds by moving successive elements (or their values in the case of pronouns and other names) from the tail end of a queue (initially the original sentence prefixed by a left marker [) to the front of a stack, and eventually executing some eligible portion of the stack and replacing it by the result of the execution.

For example, if a=. 1 2 3, and if ◊ separates the queue and stack, then b=.+/2*a would be parsed and executed as follows:

[ b =. + / 2 * a ◊
[ b =. + / 2 * ◊ 1 2 3
[ b =. + / 2 ◊ * 1 2 3
[ b =. + / ◊ 2 * 1 2 3
[ b =. + ◊ / 2 * 1 2 3
[ b =. + ◊ / 2 4 6
[ b =. ◊ + / 2 4 6
[ b ◊ =. + / 2 4 6
[ b ◊ =. 12
[ ◊ b =. 12
[ ◊ 12
◊ [ 12

The foregoing illustrates two major points: 1) Execution of the phrase 2*1 2 3 is deferred until the next element (the /) is transferred; had it been a conjunction, the 2 would have been its argument, and the monad * would have applied to 1 2 3; and 2) Whereas the value of the name a is moved to the stack, the name b (because it precedes a copula) moves unchanged. Finally, a side effect is that the pronoun b is assigned the value 12.

The executions in the stack are confined to the first four elements only, and eligibility for execution is determined only by the class of each of these elements (noun, verb, etc.). The parsing rules are prescribed more formally in Table 2.

The classes of the first four elements of the stack are compared with the first four columns of the parse table, and the first row that agrees in all four columns is selected. The bold elements in the row are then subjected to the action prescribed in column 5, and are replaced by its single result.

F. Idioms

Any phrase, such as (+*-), which cannot be evaluated according to the normal grammatical rules, can, without contradiction, be assigned any idiomatic significance desired. The idioms fork and hook are defined by the following diagrams, using f, g, and h to denote functions (i.e., verbs):

        FORK                    HOOK

   g          g            g          g
  / \        / \          / \        / \
 f   h      f   h        y   h      x   h
 |   |     / \ / \           |          |
 y   y    x  y x  y          y          y

For example, 5(+*-)3 is (5+3)*(5-3).

The sixth line of Table 2 shows the conditions for a fork: three verbs in the stack preceded by anything but a conjunction (which would, of course, seize the leading verb as its argument).

III. Definitions

Each main entry begins with a one-line header such as:

<    Ranks: _  0 0   Box ; LessThan
u/.  Ranks: _  _ _   Oblique ; Key
u@v  Ranks: mv lv rv Atop

The header begins with the word being defined, accompanied (in the case of adverbs and conjunctions) by letters that specify the case under consideration: n and v for noun and verb right arguments; m and u for left arguments.

The ranks of the verb or derived verb are shown with the monadic rank followed by the left and right ranks. An infinite rank is denoted by _, and ranks dependent on the ranks of argument verbs and nouns are shown as mv, lv, rn (for rank of n), etc.

The header concludes with suggested names for the entry. Except for minor re-ordering due to the grouping of related verbs (such as + * - %), the entries are presented in the order of the language summary of Table 1, an order also shown at the foot of each page. Arguments in the definitions are denoted by x and y.

= Ranks: _ 0 0 Classify ; Equal

MONAD. =y classifies the items of the nub of y according to equality with the items of y, producing a boolean table of shape #~.y by #y. For example:

y      ~.y     =y
abc    abc     1 0 1
def    def     0 1 0
abc

DYAD. x=y yields 1 if x is (tolerantly) equal to y. See <:.

=. =: Is(Local)/Is(Global)
Copulas, for use as in vol=. 5*area=. 3*4 and SUM=. +/. The =. is local, and =: is global, as discussed under ::. Copulas may also be used indirectly. For example, if x=.'abc';'de' and (x)=.3 4;5 6 7 then the values 3 4 and 5 6 7 are assigned to abc and de. Similarly, 'ab'=. i.2 assigns 0 to a and 1 to b and (2 3 $ 'abcdef') =. i.2 3 assigns 4 to e etc.
< Ranks: _ 0 0 Box ; LessThan

MONAD. <y is an atomic encoding of y in the sense that it has rank 0 and can be decoded (by >). See boxed nouns in Section II.A.

DYAD. x<y is 1 if x is (tolerantly) less than y. See <:.

> Ranks: 0 0 0 Open ; LargerThan

MONAD. Open (>) is the inverse of box (<), that is, y -: ><y. When applied to an open array (that has no boxed elements), open has no effect. Opened atoms are brought to a common shape as discussed in Section II.B.

DYAD. x>y is 1 if x is (tolerantly) larger than y. See <:.

<. >. Ranks: 0 0 0 Floor/Ceiling ; Min (LesserOf)/Max

MONAD. <.y gives the floor or integer part of y; thus, <. 3.1 _3.1 is 3 _4. The implied comparison with integers is tolerant (see <:), and <.y is therefore the largest integer such that (<.y)<:y. The ceiling >.y is defined by -<.-y. See <: for tolerance, and McDonnell [5] for the case of complex arguments.

DYAD. x<.y yields the lesser of x and y, and x>.y yields the larger. For example, 3 <. 4 _4 is 3 _4.

<: >: Ranks: 0 0 0 Inc(rement)/Dec ; LsOrEqual/LgOrEqual

MONAD. <:y is y-1, and >:y is y+1. Also see -..

DYAD. The result of x<:y is 1 if x is less than or equal to y, and is otherwise 0. However, the comparison is made with a certain tolerance t normally set to 2 to the power _44 but also controlled by the custom conjunction &:, as in x&:0.125 y. Formally, x<:y is 1 if |x-y does not exceed t times the larger of the magnitudes of x and y. Tolerance applies similarly to other relations, in particular to greater than or equal to (>:), to match and floor (-: and <.), but not to grade (/:).

_
The _ is not a verb, but denotes a negative number (as in _3.4), infinity (when used alone), or negative infinity (in __).
+ * - % Ranks: 0 0 0 ; Plus/Times/Minus/Divide

MONAD. The following definitions and examples apply:

Conjugate +y is (\|y*y)%y +3j5 is 3j_5
Signum *y is y% \|y *_3 0 5 is _1 0 1
Minus -y is 0-y -7 is _7
Reciprocal %y is 1%y %4 is .25

DYAD. These are defined as in elementary arithmetic except that 0%0 is 0. See McDonnell [6].

+. *. +: *: Ranks: * 0 0 ; Gcd(Or)/Lcm(And)/Nor/Nand
DYAD. x*.y is the least common multiple of x and y, and x+.y is the greatest common divisor. For boolean (0 and 1) arguments, +. is equivalent to or, and *. to and. Thus 0 0 1 1 +. 0 1 0 1 is 0 1 1 1, and 0 0 1 1 *. 0 1 0 1 is 0 0 0 1. Finally, x+:y is -.x+.y, and x*:y is -.x*.y.
-. Ranks: 0 _ _ Not(1-) ; Less

MONAD. -.y is equivalent to 1-y and, in the case of a boolean argument, to logical negation.

DYAD. x-.y are all the items of x except for those that occur as cells of y.

-: Ranks: * _ _ ; Match
DYAD. -: yields 1 if its arguments match completely, in shapes, boxing, and elements; but using tolerant comparisons. See <:.
%. Ranks: 2 _ 2 MatrixInv ; MatrixDiv

MONAD. If y is a non-singular matrix, then %.y is the inverse of y, that is, (%.y)+/..*y is the identity matrix id=. =i.#y.

More generally, %.y is defined in terms of the dyadic case as id %.y, or, equivalently, by the relation (x%.y)-:(%.y)+/..*x. The shape of %.y is |.$y. The degenerate vector and scalar cases are defined by using ;y, but the shape of the result is $y. For a non-zero vector y, the result of %.y is a vector collinear with y whose length is the reciprocal of the length of y.

DYAD. If the columns of y are linearly independent, and if #x and #y agree, then x%.y is defined to minimize the elements of r=. +/d*+d=. x-y+/..*x%.y. If y is square, it is necessarily non-singular (since its columns are independent), the elements of r are all zero, and y+/..*x%.y matches x. As in the monadic case, degenerate cases of y are treated as ;y.

Geometrically, y+/..*x%.y is, the projection of the vector x on the column space of y, the point in the space spanned by the columns that is nearest to x. Common uses of %. are in the solution of linear equations, and in the approximation of functions by polynomials (as in c=. (f x)%.x^/i.4).

%: Ranks: 0 0 0 Square Root; Root
The x-root of y (denoted by x%:y) is equivalent to y^%x. Thus, 3%:y is the cube root of y. The square root (denoted by %:y) is equivalent to 2%:y.
^ ^. Ranks: 0 0 0 Exponential/Natural Log ; Power/Log

MONAD. The exponential (^y) is equivalent to e^y, where e is Euler’s number ^1 (approximately 2.71828). The natural logarithm (^.) is inverse to ^, that is, y=^.^y, and y=^^.y.

DYAD. y^2 and y^3 and y^0.5 are the square, cube, and square root of y. The general definition of x^y is ^y*^.x, and applies for complex numbers as well as real. For a non-negative integer right argument it is equivalent to */y#x; in particular, */ applied to an empty list is 1, and x^0 is 1 for any x, including the case where x=0.

The base-x logarithm x^.y is the inverse of power in the sense that y=x^.x^y and y=x^x^.y.

u^:n Ranks: mu lu ru Power ; Chain

MONAD. The verb u is applied n times. For example, -/^:2 y is -/-/y. A negative value of n denotes |n applications of the obverse (normally the inverse) of u. Infinite n produces the limit of the application of u. Thus if y=. 1, then 2&o. ^:_ y is .73908, the solution to the equation y = Cos y.

DYAD. x u^:n y is defined as:

(x u^:(n-2)y) u (x u^: (n-1)y)

where x u^:0 y and x u^:1 y are defined as y and x u y. Thus, 0+^:(i.8)1 yields fibonacci numbers. See Tu and Perlis [7].

u^:v Ranks: mu lu ru Power ; Chain
u^:v y is equivalent to u^:(v y) y, and x u^:v y to x u^:(x v y) y.
$ Ranks: _ 1 _ ShapeOf ; Shape

MONAD. $y yields the shape of y, as defined in Section II.A.

DYAD. The shape of x$y is x,siy, where siy is the shape of an item of y. For example:

y         2 2$ y
abcd      abcd
efgh      efgh
ijkl
          ijkl
          abcd

These show that the result is formed from the items of y, the last 1-cell (abcd) showing that the selection of items is cyclic.

$. $: Suite/SelfReference
See :: (General Definition).
u~ Ranks: lv>.rv rv lv Both ; Cross
The adverb ~ commutes or crosses the connections to the argument(s). Thus, (x u~y)-:(y u x) and (u~y)-:(y u y).
~. Ranks: _ * * Nub ;

MONAD. ~.y selects the nub of y, that is, all of its distinct items:

y      ~.y     ~.3
ABC    ABC     3
ABC    DEF     $ ~.3
DEF            1

More precisely, the nub is obtained by selecting the leading item, suppressing from the argument all items (tolerantly) equal to it, selecting the leading remaining item, and so on.

~: Ranks: _ 0 0 NubSieve ; NotEqual

MONAD. The result of ~:y is a boolean list b such that b#y yields the nub of y, that is, ~.y.

DYAD. x~:y is 1 if x is (tolerantly) unequal to y. See <:.

| Ranks: 0 0 0 Magnitude ; Residue

MONAD. The magnitude of y is %:y*+y. For example, |_6 3j4 is 6 5.

DYAD. The familiar use of residue is in determining the remainder in dividing a non-negative integer by a positive integer. Thus:

   3 | 0 1 2 3 4 5 6 7 8
0 1 2 0 1 2 0 1 2

The definition :

y-x*<.y% x+0=x

extends this notion to a zero left argument (which yields the right unchanged), and to negative and fractional left arguments. For a negative left argument, the result ranges between the left argument and zero, as it does for a positive left argument. For example:

   _3 | _4 _3 _2 _1 0 1 2 3 4
_1 0 _2 _1 0 _2 _1 0 _2
   1 | 2.5 3.64 2 _1.6
0.5 0.64 0 0.4

However, to produce a true zero for cases such as (%3)|(2%3), the residue is made tolerant by the following definition: x|y is y-x*<.s if (x~:0)*.(>.s)~:<.s=.y%x+x=0 and is otherwise y*x=0.

For example, .1 | 2.5 3.64 2 _1.6 is 0 0.04 0 0. The definition also applies to complex numbers, using the properties of the floor on complex arguments.

|. Ranks: _ 0 _ Reverse ; Rotate

|.y reverses the order of the items of y, and k|.y rotates them:

y      |.y     1|.y    _1|.y
abcd   ijkl    efgh    ijkl
efgh   efgh    ijkl    abcd
ijkl   abcd    abcd    efgh
|: Ranks: _ 1 _ Transpose

MONAD. This verb reverses the order of the axes of its argument, and is equivalent to (i.-$$y)|:y.

DYAD. x|:y moves axes x of y to the tail end. If x is boxed, the axes in each box are "run together" to produce a single axis in the result. For example:

y      2 1 |:y   (<2 1) |: y
abcd   aei       afk
efgh   bfj       mrw
ijkl   cgk
       dhl       |: i. 3 4
mnop             0 4  8
qrst   mqu       1 5  9
uvwx   nrv       2 6 10
       osw       3 7 11
       ptx
u..v Ranks: 2 _ _ Determinant; DotProduct

MONAD. The expressions -/..* and +/..* are the determinant and permanent of square matrix arguments. More generally, u..v is defined in terms of a recursive expansion by minors:

('$.=. 1+0=#y.';b;'y.') :: ''

where b is

'(0{|:y.)u..v$:(<">">{0;~i.#y.){y.'

DYAD. For vectors and matrices, x+/..*y is equivalent to the dot, inner, or matrix product of mathematics, and other rank-0 functions such as <. +. and *. are treated analogously. Thus, x u..v y is defined by u x v"(lv,_1)"((1+lv),_)y.

In other words, u is applied to each of the items produced by applying v to each item of the list of "left-argument cells" and the items of y. The shapes of x and y must be such that the number of items in these left and right arguments agree. For example, if the ranks of v are 2 and 3, the shape of the result of u is sr, and the shapes of x and y are 2 3 4 5 6 and 4 7 8 9 10 11, then the shape of the result is 2 3 7 8,sr.

u:.v Obverse
The result of u:.v is the verb u but with an assigned obverse v (used as the "inverse" under the conjunctions " and ^:).
m::n Ranks: _ _ _ General Definition

If m is non-numeric, the conjunction :: produces a verb whose monadic and dyadic cases are determined by m and n, respectively. If f=. '2$:y.' :: 'y.^%x.' then f 64 is the square root and 3 f 64 is the cube root of 64. As illustrated by the foregoing, x. and y. denote the arguments and $: denotes the function being defined, thus providing the "self-reference" that is also useful in recursive definition. Also see x0: and y0:.

In general, m and n are boxed lists, the sentences in the boxes being executed in a sequence determined by the suite $.. An open list (as illustrated above) is treated as a single box, and the items of an open table are treated as a list of boxes. The following example shows the definition of an adverb g:

   b=.',x.}:$.=. y.#1'
   c=.'x.=.(x.,0)+0,x.'
   g=.'1$:y.':: (b;c)
   1 g 4
1 4 6 4 1
   g 4
1 4 6 4 1

The suite $. determines the sequence in which the sentences are executed. It is initially set to i.ns, where ns is the number of sentences; in the present example, it is reset to execute sentence 1 the number of times specified by the right argument. The explicit result of the verb is the result of the sentence executed last.

Any name assigned by the copula =. is made strictly local on its first assignment; that is, values assigned to the name have no effect on the use of the name outside of the verb or within other verbs invoked by it. The names x. y. $. $: are also local.

If sentence k begins with a name followed by a right parenthesis, the name is made local and set to k}.i. ns. Such a label is useful in setting the suite to effect branching.

Adverbs. If m is 1, then m::v yields an adverb. If r=. 1::'|.&x.&|.', then -/\r 1 2 3 4 yields 2 3 1 4.

Conjunctions. If m is 2, then m::n produces a conjunction. For example, if:

   p=.'$.=.1,y.#2'
   q=.'a=.{:';'a=.x.&a'
   pow=.2:: (p;q)

then o.pow 2 (1) is the square of pi.

m::v u::n u::v Definition
The first argument specifies the monadic case, and the second argument the dyadic case, using in m and n the conventions defined under the case m::n above.
, Ranks: _ _ _ Ravel ; Append

MONAD. ,y gives a list of the atoms of y in "normal" order; the result is ordered by items, by items within items, etc. The resulting shape is 1$*/$y. Thus, (,i. 2 3 4)-:i.*/2 3 4.

DYAD. x,y appends items of y to items of x after 1) Reshaping one atomic argument to the shape of the items of the other, 2) Bringing the items to a common rank (of at least 1) by repeatedly itemizing (,:) any of lower rank, and 3) Bringing them to a common shape by using overtake ({.). Compare with the "permissive frame-building" in Section II.B. For example, if y=.i.2 3:

'abc','d'    5 6 7,y    y,7
abcd         5 6 7      0 1 2
             0 1 2      3 4 5
             3 4 5      7 7 7
,. Ranks: _ * * Raze;

MONAD. ,.y assembles along a leading axis the opened elements of the ravel of y. For example:

y              ,.y
┌─┬────┬──┐    isingof
│i│sing│of│
└─┴────┴──┘
,: Ranks: _ _ _ Itemize ; Laminate

MONAD. ,:y adds a single unit axis to y, making the shape 1,$y.

DYAD. An atomic argument in x,:y is first reshaped to the shape of the other; the arguments are then itemized and appended, as in (,:x),(,:y).

; Ranks: _ _ _ Table ; Link

MONAD. ;y is a table formed by ravelling the items of y. In particular, the result has shape 1 1 if y is an atom.

DYAD. x;y is (<x),y if y is boxed, and (<x),<y if y is open.

u;.n Ranks: _ 1/2 _ Cut

Cases ;.0 and ;.3 have left rank 2. Others have left rank 1.

MONAD. The phrase u;.1 y applies u to each of a set of intervals of items of y to produce the items of the result. Each interval begins at an occurrence of the delimiter 0{y. For example:

   <;.1 y=. ' worlds on worlds'
┌───────┬───┬───────┐
│ worlds│ on│ worlds│
└───────┴───┴───────┘
   b=. 5 3$i.9
   $;.1 y
7
3
7
   b
0 1 2
3 4 5
6 7 8
0 1 2
3 4 5
   (+/;.1)b
9 12 15
3  5  7

The phrase u;._1 y differs only in that the delimiters are excluded from the intervals. In the cases u;.2 and u;._2 the delimiter is the last item, and marks the ends of intervals.

The phrase u;.0 y applies u to y after reversing y along each axis, and is equivalent to (0 _1*/$y)u;.0 y.

The monads u;.3 and u;._3 apply u to tesselation by "maximal cubes", that is, they are defined by their dyadic cases using the left argument ($$y)$<./$y.

DYAD. The dyads u;.1 and u;._1 and u;.2 and u;._2 differ from the monads in that the intervals are delimited by the ones in the boolean argument x. For example, if x=. 0 1 0 0 1 and y=.i.5 3:

y          x +/;.1 y
 0  1  2   18 21 24 7
 3  4  5   12 13 14
 6  7  8     x+/;.2 y
 9 10 11    3  5  7
12 13 14   27 30 33

The phrase x u;.0 y applies u to a "rectangle" or "parallelepiped" of y with one vertex at the point in y indexed by v=. 0{x, and with the opposite determined as follows: the dimension is |1{x, but the rectangle extends back from v along any axis k for which the index k{0{x is negative. Finally, the order of the selected elements is reversed along each axis k for which k{1{x is negative. For example, (1 _2,:_2 3)+;.0 i.4 5 is 11 12 13;6 7 8.

The cases u;.3 and u;._3 provide (possibly overlapping) tesselations. The phrase x u;._3 y applies u to each complete rectangle of size |1{x obtained by beginning at all positions obtained as integer multiples of (each element of) the movement vector 0{x. As in u;.0, reversal of each piece occurs along an axis for which the "window" 1{x is negative.

The degenerate case of a list x is equivalent to the left argument 1,:x, and therefore provides a complete tesselation of size x.

The case u;.3 differs from u ;._3 only in that any shards of sizes less than |1{x are included. For example:

y         (3 2;2 3)<;.3 y
abcdef    ┌───┬───┬──┐
ghijkl    │abc│cde│ef│
mnopqr    │ghi│ijk│kl│
stuvwx    ├───┼───┼──┤
yzABCD    │stu│uvw│wx│
          │yzA│ABC│CD│
          └───┴───┴──┘
;: Ranks: 1 * * Words
MONAD. ;: y is the list of boxed words in the list y according to the rhematic rules of Part I.
# Ranks: _ 1 _ Tally ; Copy

MONAD. #y is 1 if y is an atom, and is otherwise the number of items in y.

DYAD. If the arguments have an equal number of items, then x#y copies +/x items from y, with i{x repetitions of item i{y; if one is an atom, it is repeated to make the item count of the arguments equal; if both are atoms, they are treated as one-element lists.

#. Ranks: 1 1 1 Base2 ; Base-x

MONAD. The base-2 value of y, that is, 2#.y.

DYAD. A weighted sum of the items of y; that is, +/w*y, where w=. *\}.x,1. For example, 10 #. 1 2 3 is 123, and 24 60 60 #. 1 2 3 is 3723.

#: Ranks: _ 1 0 Antibase2 ; Antibase

MONAD. #: y is the representation of y in base 2, equivalent to (m#2)#:y, where m is the maximum of the number of digits needed to represent the elements of y in base 2. For example:

   |:#:i.8
0 0 0 0 1 1 1 1
0 0 1 1 0 0 1 1
0 1 0 1 0 1 0 1

DYAD. For simple cases, #: is inverse to #. and, in general, x#.x#:y is (*/x)|y.

u@v Ranks: mv lv rv Atop
The monad u@v y is equivalent to with (u&v y). The dyad x u@v y is defined as u x v y. For example, 3|@-7 is 4.
@. Ranks: 1 1 _ Permute

MONAD and DYAD. If p is a permutation of the atoms of i.n, then p is said to be a permutation vector of order n, and if n=#b, then p{b is a permutation of the items of b.

@.p yields a list of boxed lists of the atoms of i.#p called the standard cycle representation of the permutation p. For example, if p=. 4 5 2 1 0 3, then @.p is (,2);4 0;5 3 1 because the permutation p moves to position 2 the item 2, to 4 the item 0, to 0 the item 4, to 5 the item 3, to 3 the item 1, and to 1 the item 5. The monad @. is self-inverse; applied to a standard cycle it gives the corresponding direct representation.

A given permutation could be represented by cycles in a variety of ways; the standard form is made unique by the following restrictions: the cycles are disjoint and exhaustive (i.e., the atoms of the boxed elements together form a permutation vector); each boxed cycle is rotated to begin with its largest element; and the boxed cycles are put in ascending order on their leading elements.

Non-Standard Representations. If p and c are standard and cycle representations of order #b, then p@.b and c@.b produce the corresponding permutations of items of b. More generally, since the tally of b determines the order of the permutation, the arguments p and c may be non-standard in ways to be defined. In particular, negative integers down to -#b may be used, and are treated as their residues modulo #b.

If q is not boxed, and if the elements of (#b)|q are distinct, then q@.b is equivalent to p@.b, where p is the standard form of q given by p=. ((i.n)-.n|q),n|q, where n=. #b. In other words, positions occurring in q are moved to the tail end.

If q is boxed, the elements of (#b)|>j{q must be distinct for each j, and the boxes are applied in succession. Thus, (2 1;3 0 1)@.i.5 is (<2 1)@.(<3 0 1)@.i.5, and the result of either is the standard direct permutation 1 2 3 0 4.

The transformation provided by the monad @. is extended to non- negative non-standard cases by treating any argument q as a representation of a permutation of order 1+>./,.q.

@: Ranks: 1 0 _ Atom;AtomPermute

MONAD and DYAD. If T is the table of all !n permutations of order n arranged in lexical order (that is, /:T is i.!n), then k is said to be the atom representation of the permutation k{T. Moreover, k@:b permutes items of b by the permutation of order #b whose atom representation is (#b)|k. For example, 1@:b transposes the last two items of b and _1@:b reverses all items, and 3@:b and 4@:b rotate the last three items of b. Finally, (i.!n) @:i.n produces the ordered table of all permutations of order n, as does (i.&!@:i.)n.

The monad @: applied to any cycle or direct permutation yields its atom representation. For example, @: 0 3 2 1 is 5, as are @:3 2 1 and @: 0;2;3 1 and @: <3 1.

u/ Ranks: _ _ _ Insert ; Function Table

MONAD. u/y applies the dyad u between the items of y. Thus:

   i. 3 2
0 1
2 3
4 5
   +/i. 3 2
6 9
   */1 2 3
6

If y has no items (that is, 0=#y), the result of u/y is the identity element of the verb u. An identity element of a function u is a value e such that either x-:x u e or x-:e u x for every x in the domain (or perhaps some significant sub-domain such as boolean) of u. This definition of insertion over an argument having zero items, extends partitioning identities such as (+/y) -: (+/k{.y)+(+/k}.y) to the cases k=.0 and k=.#y.

The identity function of a verb u is a function ifu such that (ifu y) -: (u/y) if 0=#y. Denoting v inverse by iv, the identity functions are:

$&0&}.&$              < > + - +.~:|
$&1&}.&$              = <:>:* % *.%:^ !
$&_&}.&$              <.
$&__&}.&$             >.
i.&(0&,)&(2&}.)&$     ,
i.&(1&{.)&}.&$        @.{
=&i.&(1&{.)&}.&$      %.+/..*
ifu&#                 u/
$&(iv ifu$0)&}.&$     u"v

DYAD. If x and y are numeric lists, then x */ y is their multiplication table. For example:

   1 2 3 */4 5 6 7
 4  5  6  7
 8 10 12 14
12 15 18 21

In general, each cell of x is applied to the entire y, that is, x u/y is x u"(lu,_)y.

u/. Ranks: _ _ _ Oblique ; Key

MONAD. If a=.i.3 4, then </.a is (,0);1 4;2 5 8;3 6 9;7 10;,11, that is, the (3+4)-1 elements of the result are obtained by applying < to each of the oblique lines of y. Hence, if p and q are the coefficients of two polynomials, +//.p*/q yields the coefficients of the product polynomial.

More generally, u/.y is the result of applying u to the oblique lines of _2-cells of y. If the rank of y is less than two, y is treated as the table ;y.

DYAD. x u/.y is (=x)u@#y, that is, items of x specify keys for the corresponding items of y, and u is applied to each of the collections of y having identical keys. For example, 1 2 3 1 3 2 1 </.'abcdefg' yields 'adg';'bf';'ce'.

/: \: Ranks: _ 1 _ GradeUp/GradeDown;Sort

MONAD. /: grades its argument, yielding a permutation vector such that (/:y){y sorts y in ascending order. For example:

   {:g=. /:y=. 3 1 4 2 1 3 3
1 4 3 0 5 6 2
   g{y
1 1 2 3 3 3 4

As illustrated above, elements of g that select equal elements of y occur in ascending order.

If y is a table, /:y grades the base value of the rows, using a base larger than the magnitude of any of the elements. A y of higher rank is treated as ;y, that is, as if its items were each ravelled.

If y is literal, /:y grades according to the collating sequence specified by the alphabet a.; any other collating sequence cs can be imposed by grading the result of cs i. y.

Downgrade is like upgrade, except that the items of (\:y){y are in descending order.

DYAD. x /: y is defined by (/:y){x; that is, x is sorted into an order specified by y. In particular, y/:y (or /:~y) sorts y.

u\ u\. Ranks: _ 0 _ Scans:Prefix/Suffix;Infix/Outfix

MONAD. u\y has #y items resulting from applying u to each of the prefixes k{.y, for k from 1 to #y. Thus, <\'abc' yields (,'a');'ab';'abc', and +/\1 2 3 4 is 1 3 6 10.

u\.y has #y items resulting from applying u to suffixes of y, beginning with one of length #y (that is, y itself), and continuing through to a suffix of length 1.

DYAD. If a is positive, then the items of a u\y result from applying u to each infix of length a. If a is negative, then u is applied to the non-overlapping infixes of length |a, including a possible final shard . Thus, 2<\q=. 'abcde' is 'ab';'bc';'cd';'de', and _2<\q is 'ab';'cd';,'e'.

If a is positive in the expression a u\. y, then u applies to the outfixes of y obtained by suppressing successive infixes of length a. If a is negative, the outfixes are determined by suppressing non-overlapping infixes, the last of which may again be a shard. For example, 2<\.q is 'cde';'ade';'abe';'abc'.

{ Ranks: 1 0 _ Catalog;From

MONAD. {y forms a catalog from the atoms of its arguments, its shape being the chain of the shapes of the opened items of y, and the common shape of the boxed results is $ y. The case {a;<b is called the cartesian product of a and b. Thus:

   {'ht';'ao';'gtw'
┌───┬───┬───┐
│hag│hat│haw│
├───┼───┼───┤
│hog│hot│how│
└───┴───┴───┘

┌───┬───┬───┐
│tag│tat│taw│
├───┼───┼───┤
│tog│tot│tow│
└───┴───┴───┘
   >{10 11;i.2 2
10 0
10 1

10 2
10 3


11 0
11 1

11 2
11 3

DYAD. If x is an integer in the range from -#y to <:#y, then x{y selects item (#y)|x from y. More generally, x may be a boxed list, whose successive elements are (possibly) boxed lists that specify selection along successive axes of y. For example:

y        2 0{y     (<2 0){y
abcdef   mnopqr    m
ghijkl   abcdef    (<2 0;1 3){y
mnopqr             np
                   bd

Finally, if any r=.>j{>x used in the selection is itself boxed, selection is made by the indices along that axis (i.j{$y) that do not occur in >r. Thus, (<(<<2 0),(<<1 3)){y is gikl.

m} u} Ranks: _ _ _ Merge

The function m} is equivalent to m&{}.

MONAD. u}y is a merge of the items of y whose shape is the shape of an item of y. Each atom in the merge is selected as a corresponding atom in an item, the particular item being specified by the index in the corresponding position of u i.}.$y (whose shape must be the shape of an item of y). For example, if m=.0 1 3 1 2, and u=.m&{, then:

y       u i.}.$y     u}y
abcde   0 1 3 1 2    agrio
fghij                m}y
klmno                agrio
pqrst

DYAD. If x has the same shape as the index array j=. u i.$y, then x u}y produces a merge of x and y by inserting the atoms of x in the selected positions of y. More generally, the shape of x may be a suffix of the shape of j, and the result is a merge of ($j)$,x and y. For example, if x=. 'AGMS' and u=.(<0 1)&|: (the diagonal function), then:

y       u i.$y        x u}y    'Z' u}y
abcde   0 6 12 18     Abcde    Zbcde
fghij                 fGhij    fZhij
klmno                 klMno    klZno
pqrst                 pqrSt    pqrZt
{. Ranks: _ 1 _ First;Take

MONAD. {. y selects the leading item of y; that is, y if y is an atom, and 0{y if it is not.

DYAD. If x is an atom, x{.y takes from y an interval of |x items; beginning at the front if x>:0, and ending at the tail if x<0. For example:

y     2{.y    4{.y    _4{.y
0 1   0 1     0 1     0 0
2 3   2 3     2 3     0 1
4 5           4 5     2 3
              0 0     4 5

In an overtake (as in 4{.y and _4{.y above), extra items consist of fills; zeros if y is numeric, boxed empties if it is boxed, and spaces otherwise. If y is an atom, the result of 1{.y is a one-element list. Finally, if $y is 0,s, then the fill items are s$0.

In general, x may be a vector of length no more than $$y; the effect of element k is (k{x){."(($$ y)-k)y.

}. Ranks: _ 0 _ Rest;Drop

MONAD. }. y selects the rest of the items of y after the first, and is equivalent to 1}.y.

DYAD. x}.y drops (at most) x items from y in a manner similar to {..

{: }: Ranks: _ _ _ Right/Left
Both monads are nilpotent, yielding their arguments. The dyad {: yields its right argument, and }: the left.
m"n Ranks: |.3$ |.n Constant
The ranks of the derived verb are specified directly by n if it has three elements, and otherwise by |.3$ |.n. Thus a single element specifies all ranks, and the last of two elements specifies the monadic and right ranks. The derived verb m"n produces the constant result m for each cell to which it applies.
u"n Ranks: |.3$|.n Rank
The function u"n is identical to u except that its ranks are determined by n as specified under m"n.
u"v Ranks: mv lv rv Rank
The function u"v is equivalent to u except that its ranks are the ranks of v.
". Ranks: 1 1 1 Execute

MONAD. ".y is the result of executing the character list y. Thus, ".'a=.3+4' assigns the value 7 to the name a and yields the explicit result 7. The result of ".'' is the empty list.

DYAD. x".y is the result of ".y if y is a valid sentence (whose execution finishes properly). Otherwise it is the result of ".x, which may invoke an error report in the normal manner.

": Ranks: _ 1 1 Format

MONAD. ":y is equivalent to x":y, where x is chosen to provide a minimum of one space between columns. Default output is identical to this monadic case.

DYAD. x":y produces characters from the alphabet a. that represent y in a format specified by x. Each element e of x controls the representation of the corresponding element of y as follows:

w=.<.|e specifies the total width allocated; if this space is inadequate, the entire space is filled with asterisks. If e is zero, enough space is allocated.

d=.<.10*(|e)-w specifies the number of digits following the decimal point (which is itself included only if d is not zero).

Any negative sign is placed just before the leading digit.

If e>:0, the result is right justified in the space w.

If e<0, the result is put in exponential form (with one digit before the decimal point) and is left-justified except for two fixed spaces allowed on the left (including one for a possible negative sign).

Boxed elements are displayed in boxes, as shown in Section II.A.

The custom conjunction specifies the number of digits of precision for real numbers. For example, ":&:4 (5%3) yields 1.667.

m&v u&n Ranks: (rm>.rv)/(lu>.rn) * * With
m&v y is defined by m v y, and u&n y by y u n.
u&v Ranks: mv mv mv With

MONAD. u&v y is defined by u v y, applying individually to the cells of rank mv.

DYAD. x u&v y is defined by (v x) u (v y).

u&.v Ranks: mv mv mv Under

The function u&.v is equivalent to the composition u&v except that the function obverse to v is applied to the result for each cell. The obverse pairs are specified by the conjunction :. or by:

+ - % |. |: {: }: < %. -. #. /: <: #. ". ^ %:
+ - % |. |: {: }: > %. -. #. /: >: #: ": ^. ^&2

For example, the phrase x+&.^.y yields the product of x and y, and |.&.>y reverses each of the boxed elements of y.

&: Custom
Unlike other conjunctions, this one applies in a manner specific to each verb. For the relations, its right argument specifies the tolerance to be used, as in <&:(2^_44). For other verbs (such as ":), the effects are discussed in their definitions.
! Ranks: 0 0 0 Factorial;Outof

MONAD. For a non-negative integer y, the definition of !y is */>:i.y. In general, !y is gamma >:y.

DYAD. For non-negative arguments x!y is the number of ways that x things can be chosen out of y. In general it is defined as (!y)%(!x)*(!y-x), with the understanding that infinities (occasioned by ! on a negative integer) cancel if they occur in both numerator and denominator. For example:

   !/~3-~i.7
  1 _2  1 0 0 0 0
  0  1 _1 0 0 0 0
  0  0  1 0 0 0 0
  1  1  1 1 1 1 1
 _3 _2 _1 0 1 2 3
  6  3  1 0 0 1 3
_10 _4 _1 0 0 0 1
!: External
This conjunction is used to communicate with the operating system as well as with the keyboard (as an input file) and with the screen (as an output file). See Appendix B.
? Ranks: 0 0 0 Roll;Deal

MONAD. ?y yields a uniform random choice from i.y.

DYAD. x?y yields a list of x items chosen at random without repetition from the list i.y.

) Label-Command
This parenthesis sets off a label in function definition (See ::), and introduces a command to change certain parameters as detailed in Appendix A.
a. Alphabet
a. is a list of the elements of the alphabet; it determines the collating sequence used in sorting (/: and \:).
e. Ranks: _ 0 _ RazeIn;In

MONAD. e.y produces a boolean result that determines for each atom of y whether its open contains each item of the raze of y. Thus:

   y=. 'abc';'dc';'a'
   ,.y
abcdca
   e.y
1 1 1 0 1 1
0 0 1 1 1 0
1 0 0 0 0 1

DYAD. If x has the shape of an item of y, then xe.y is 1 if x matches an item of y. In general, xe.y is (#y)>y i.x. For example:

   'cat' e. 'abcd'
1 1 0
   'cat' e. 2 3$'catdog'
1
E. Ranks: * _ _ ;In

DYAD. If b=.x E. y, then the ones in b indicate the beginning points of occurrences of the pattern x in y. For example:

   'co'E.'cocoa'
1 0 1 0 0
   (0 1+/i.3)E.4|+/~i.5
1 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 1 0 0 0
0 0 0 0 0
i. Ranks: 1 _ _ Integers;IndexOf

MONAD. The shape of i.y is |y, and its atoms are the first */y non-negative integers. For example:

   i.2 3
0 1 2
3 4 5
   i.2 _3
2 1 0
5 4 3
   i.''
0
   i._4
3 2 1 0

As shown in the examples, a negative element in y causes reversal of the atoms along the corresponding axis.

DYAD. If rix is the rank of an item of x, then the shape of the result of xi.y is (-rix)}.$y. Each atom of the result is either # x, or the index of the first occurrence among the items of x of the corresponding rix-cell of y.

o. Ranks: 0 0 0

MONAD. o. y yields pi times y. For example, o.1 is 3.14159.

DYAD. k o. y is one of the circular, hyperbolic, or pythagorean functions, according to the following table:

k function k function
0 %:1-y^2 7 Tanh y
1 Sine y 8 %:_1-y^2
2 Cosine y 9 (y++y)%2
3 Tangent y 10 \|y
4 %:1+y^2 11 (y-+y)%0j2
5 Sinh y 12 (^.*y)%0j1
6 Cosh y

The function (-k)o.y is inverse to ko.y. In particular, the cases _1, _4, _9, and _10, are Arcsine y, %:_1+y^2, y, and +y. The arguments of Sine, Cosine, and Tangent (and the results of their inverses) are in radians.

x. y.
These denote the arguments in a definition as defined for under General Definition (::)

References

  1. Falkoff, A.D., and K.E. Iverson, The Design of APL, IBM Journal of R&D, July 1973 and The Evolution of APL, ACM Sigplan Notices, August 1978.
  2. Hui, et al., APL\?, APL90, ACM.
  3. Iverson, K.E., A Dictionary of APL, ACM APL Quote-Quad, September 1987.
  4. Iverson, K.E., J, Vector (British APL Assoc.), August 1990.
  5. McDonnell, E.E., Complex Floor, APL73, North Holland.
  6. McDonnell, E.E., Zero Divided by Zero, APL76, ACM.
  7. Tu, Hai-Chen, and A.J. Perlis, IEEE Software, January 1986.

Acknowledgments

I am indebted to Mr. Roger Hui for his rapid development of a flexible, reliable, and highly portable implementation of J, for his close collaboration in the design of the language, for critical reading of successive drafts of the dictionary, and for significant contributions to the treatments of certain topics, in particular, the identity functions.

Appendix A: System Commands

The following commands may be entered at any point in a session; the leading right parenthesis distinguishes them from normal sentences. Brackets indicate that the argument y is optional; when omitted, the present value of the parameter is printed.

A right parenthesis may also be used to specify a label, as described under the conjunction :: (definition).

)box [y]
The eleven-element integer list y specifies the indices of the ASCII characters to be used in displaying boxed arrays, in the order : ┌ ┬ ┐ ├ ┼ ┤ └ ┴ ┘ │ ─
)clear
Restore to initial condition, erasing all names.
)off
Terminate session.
)prompt [y]
The prompt for immediate input is specified by y. The default value is ' ' (that is, three spaces).
)reset
Terminate all suspended functions.
)rl [y]
The "random link" used as a "seed" by the random number generator (?) is specified by y. The default value is 16807.
)script [y]
The argument is one (quoted) file name for input or two (as in 'abc' 'defg') for input and output. Except that system commands are ignored, the entire input file is executed as a script before further input is accepted from the keyboard. An unquoted dash (-) for the input file denotes keyboard input. The output is directed to the screen as well as to any designated output file. An output file so generated is suitable as the input in a subsequent command.
)sscript [y]
Behaves like )script, except that output does not appear on the screen.
)si
Stack Indicator, showing functions currently suspended.

Appendix B: External Conjunction

0!:0 y
The list y is executed by the host system, and the result is returned.
1!:0 y
Directory.
1!:1 y
File read: y designates a file to be read, and the result is a string of the file contents; y may be a boxed name suited to the host file system, or it may be the number 1, designating the keyboard as the source file.
x 1!:2 y
File write: x is a string, and y is a boxed file name, or the number 2 designating screen output.
x 1!:3 y
File append (like x 1!:2 y, but appends rather than replaces).
1!:4 y
File size: y is a boxed file name.
1!:55 y
File erase: y is a boxed file name.
3!:0 y
Storage type of the noun y, encoded as 2^i.6 for boolean, literal, integer, floating, complex, boxed.
3!:1 y
Convert to internal representation (of a noun y).
3!:2 y
Convert from internal representation.
4!:0 y
Name class of boxed name, encoded as i.7 for undefined (but valid), label, noun, verb, adverb, conjunction, other.
[x] 4!:1 y
Name list: result is a list of boxed names belonging to the classes 1 to 5 (as shown in 4!:0) in y. The optional left argument lists the initial letters of names to be included.
4!:55 y
The boxed name y is erased.
5!:0 y
Fix: (Inverse of 5!:1 and 5!:2).
5!:1 y
Canonical representation.
5!:2 y
The boxed representation of a boxed name y.
6!:0 y
Time stamp: the current time as a list in the order YMD HMS. The last element may be fractional.
6!:1 y
Time since start of session.
6!:2 y
Time required to execute the sentence y.
6!: 3 y
Delay for y seconds.
7!:0 y
Space currently in use.
7!:1 y
Space used since start of session.
7!:2 y
Space required to execute the sentence y.
128!:0 y
QR decomposition of y in the domain of %., giving a boxed Hermitian matrix and a boxed upper triangle.
128!:1
Invert square upper triangle.

Table 1: Language Summary

. : Page
= Classify ; Equal Is (Local) Is (Global) 5
< Box ; LessThan Floor ; LesserOf Decrem ; LsOrEq
> Open ; LargerThan Ceiling ; LargerOf Increment ; LgOrEq 6
_ NegSign/Infinity
+ Conjugate ; Plus ; GCD (Or) ; Nor
* Signum ; Times ; LCM (And) ; Nand
- Negate ; Minus Not (1-) ; Less ; Match
% Recip ; Divide MatrixInv ; MDiv Sqrt ; Root 7
^ Exp ; Power NaturalLog ; Log Power ; Chain
$ ShapeOf ; Shape Suite SelfReference
~ Both ; Cross Nub ; Nubsieve ; NotEq
\| Mag ; Residue Reverse ; Rotate Transpose 8
. Determ ; DotProd
: Obverse Definition 9
, Ravel ; Append Raze ; Itemize ; Laminate
; RavelItems ; Link Cut Words ; 10
# Tally ; Copy Base2 ; Base Ant2 ; Antibase 11
@ Atop Dir-Cyc ; Permute AtomPermute
/ Insert ; Table Oblique ; Key GradeUp ; Sort 12
\ Prefix ; Infix Suffix ; Outfix GrDown ; Sort
{ Catalog ; From First ; Take Right (Dex) 13
} Merge Rest ; Drop Left (Lev)
" Rank Execute ; Execute Format ; Format 14
& With Under Custom
! Factorial ; OutOf External 15
? Roll ; Deal
) Label-Cmd (Appendix A)
a Alphabet
e Razein ; Member
i Integers ; IndexOf
o PiTimes ; Circular
x First Argument 16
y Last Argument
E ; MemberOfInterval

Table 2: Parsing Rules

[=(av v n & Monad
c n v n Monad
[=(avn n v n Dyad
[=(avn nv a & Adverb
[=(avn nv c nv Conjunction
[=(avn v v v Fork
[=( v v & Hook
np = cavn= & Is
( cavn ) & Punctuation
& & & & Get next

LEGEND: a Adv; c Conj; n Noun; p Pronoun; v Verb; [ Lmark; = Is; ( Lparen; ) Rparen; & Any