Built-ins
| name | type | what it does |
|---|---|---|
+ | Num a => a -> a -> a | Plus. |
− | Num a => a -> a -> a | Minus. Written spaced ( |
× | Num a => a -> a -> a | Times, drawn as the times sign. |
^ | Num a => a -> a -> a | Power, spaced: |
m̲ax | Num a => a -> a -> a | The larger of two numbers; |
m̲in | Num a => a -> a -> a | The smaller of two numbers. |
÷ | Num a => a -> a -> Float | Divide, drawn as the division sign; the result is a Float. |
d̲iv | Int -> Int -> Int | Whole-number division, in maths order: |
m̲od | Int -> Int -> Int | Remainder, in maths order: |
n̲eg | Num a => a -> a | Negate. |
a̲bs | Num a => a -> a | Absolute value. |
f̲loor | Num a => a -> Int | Round down to an Int. |
c̲eiling | Num a => a -> Int | Round up to an Int. |
e̲xp | Num a => a -> Float | e to a power. |
l̲og | Num a => a -> Float | Natural logarithm. |
f̲loat | Num a => a -> Float | An Int as a Float. |
s̲in | Num a => a -> Float | Sine. |
c̲os | Num a => a -> Float | Cosine. |
a̲tan | Num a => a -> Float | Arctangent, the angle whose tangent is the argument. |
p̲i | Unit -> Float | The constant pi. It is niladic, so it is applied to |
= | (Eq a, Truthy b) => a -> a -> b | Equal (any scalar type). |
≠ | (Eq a, Truthy b) => a -> a -> b | Not equal. |
< | (Ord a, Truthy b) => a -> a -> b | Less than (numbers and characters). |
> | (Ord a, Truthy b) => a -> a -> b | Greater than. |
≤ | (Ord a, Truthy b) => a -> a -> b | At most. |
≥ | (Ord a, Truthy b) => a -> a -> b | At least. |
e̲q~ | (Num a, Truthy b) => a -> a -> b | Equal within a small tolerance, for Floats. |
∧ | (Truthy a, Truthy b) => a -> a -> b | And. |
∨ | (Truthy a, Truthy b) => a -> a -> b | Or. |
n̲ot | (Truthy a, Truthy b) => a -> b | Not. |
p̲rint! | a -> a | Print a value and give it back (the ! marks an effect). |
r̲oll! | Int -> Int | A random whole number from 1 to n for every n (seeded here, so the example repeats). |
i̲d | a -> a | The value itself. As the left function of a fork it gives the argument unchanged: |
l̲eft | a -> b -> a | The left argument. In a dyadic train, |
r̲ight | a -> b -> b | The right argument. |
⎕A | Char | The alphabet, the uppercase letters: a system value, written without an underline and read where it is used. |
⎕D | Char | The digits, as characters. |
⎕AV | Char | The atomic vector: every character, ASCII 0 to 127 (source is ASCII), so a character's code is its place in it, less one. |
⎕IO | Int | The index origin: always 1 (there is no setting). |
⎕TS | Int | The local time stamp: year, month, day, hour, minute, second and millisecond, read each time it is used (a host without a clock reports |
⎕D̲L | Num a => a -> Float | Wait the given seconds (an Int or a Float); the result is the seconds actually waited, at least those asked for. A negative delay is an error. |
⎕U̲CS | Char -> Int | The code of each character, keeping the shape. Codes go back to characters with |
⎕U̲CHAR | Int -> Char | The character of each code, 0 to 127; another code is an error. |
⎕N̲PUT | Char -> Char -> Int | Write the text on the left to the file on the right (made, with its directories, if missing); how many characters it wrote. |
⎕N̲GET | Char -> Char | A file's text. |
⎕R̲EAD | Unit -> Char | A line typed at the keyboard (here, the line "a typed line"). |
⎕E̲RR | Char -> Char | Write a line to standard error (red in the live demo), and give the text back. |
⎕P̲ANIC | Char -> a | Stop the program with error[panic] and the text as its message (what |
⎕S̲IGNAL | Char -> Char -> a | Stop with an error of your own: the code on the left names the error class, as xetal's own codes do (lowercase letters, digits and hyphens), and the text on the right is its message. Uncaught, it ends the program with exit status 1, like any error. Its result has any type. |
⎕W̲ARN | a -> Box Char -> a | An error the program can go on from (a warning): the left argument is the value to go on with, of the type of the place the warning stands in, and the right is the code and the message, a strand of two strings. Uncaught, a warning is an error like a signal. A handler that answers |
⎕T̲RAP | (Unit -> a) -> (Error -> Outcome a) -> a | Run the body; on any error, call the handler with it. The trap's value is the body's, or what the handler recovers with. |
⎕E̲NSURE | (Unit -> a) -> (Unit -> b) -> a | Run the body, then the cleanup (a function of |
⎕R̲ECOVER | a -> Outcome a | The handler's answer: the trap's value is this one, of the body's type. |
⎕R̲ETRY | Error -> Outcome a | The handler's answer: run the body again. After 1000 runs the trap gives up with error[retry-limit]. |
⎕H̲ALT | Error -> Outcome a | The handler's answer: the error goes on as it was, from where it was raised. A handler for one kind of error halts on the others. |
⎕C̲ONTINUE | Error -> Outcome a | The handler's answer to a warning: go on from it, with its value. The handler runs where the warning was raised, before any cleanup between it and the trap, so nothing has been undone. Halting a warning passes it outward still a warning; continuing an error raised by |
⎕E̲CODE | Error -> Char | The code of a caught error ( |
⎕E̲MESSAGE | Error -> Char | The message of a caught error. |
⎕E̲WHERE | Error -> Char | Where a caught error was raised, as errors print it: the span of source text, |
⎕T̲E | Unit -> Int | The terminal's facts: rows, columns, 1 when output is a terminal, 1 when it does screen control (here, output to a file). |
⎕K̲EY | Unit -> Key | One key, without Enter, as a Key (here, the key a): the terminal reads it raw; in the live demo the program waits in the terminal pane. Keys are named in the Terminal library ( |
⎕K̲CHAR | Key -> Char | A printing key's character, or nothing for a named key such as Up. |
⎕K̲NAMED | Int -> Key | Named key n (1 to 11: Up, Down, Left, Right, Enter, Escape, Backspace, Tab, Delete, Home, End), for the Terminal library, which names them. |
⎕V̲IEW | Char -> Box Char | Source text as the editor and the HTML export see it: a matrix of boxed texts, a row per run of one class, two columns: the decorated text (underlines drawn, as |
⎕L̲IST | Char -> Char -> Box Char | A top-level list of strings in a TOML file, as boxed texts: |
⎕T̲ABLE | Box Char -> Box Char -> Box Char | A table of tables in a TOML file as a matrix of texts whose rows and columns follow two top-level lists: |
⎕E̲VENT | Unit -> Event | The next event from the host, as an Event: a tick of the clock, a pointer down, move, up or click, a key, or |
⎕E̲KIND | Event -> Char | What kind an event is, as text: |
⎕E̲AT | Event -> Float | An event's numbers: |
⎕E̲KEY | Event -> Key | A key event's key ( |
⎕C̲OLOR | Int -> Color | Color n (1 to 8: black, red, green, yellow, blue, magenta, cyan, white), for the Terminal library, which names them ( |
⎕F̲G | Color -> Char -> Char | Text in a foreground color: the text wrapped in the codes a terminal (or the live demo's grid) colors it with; print it to see it. Here, its length: five characters on each side of the text. |
⎕B̲G | Color -> Char -> Char | Text on a background color, as []F_G does the foreground. |
⎕B̲OLD | Char -> Char | Text in bold (wrapped in its codes, as []F_G). |
⎕A̲T | Int -> Char -> Char | Text placed at a row and a column (1-origin), for a program that draws a screen: the code moving the cursor there, then the text. |
⎕C̲LS | Unit -> Char | The text that clears the screen and moves the cursor home; print it. |
f̲ormat | a -> Char | A value as the text it prints as. |
n̲umbers | Char -> Float | The numbers in a text, as Floats. |
⎕R̲EJECT | Char -> Char -> Char | Fail the macro call being expanded: the left text is a code and where to report it (call, left or right), the right text the message. |
⎕S̲TATEMENT | Truthy a => Unit -> a | Whether the call being expanded stands as a statement of its own. |
⎕F̲ILE | Unit -> Char | The file the call being expanded is written in ( |
⎕L̲INE | Unit -> Int | The line the call being expanded is written on ( |
⎕I̲NCLUDE | Char -> Char | The text of a file, by a path relative to the file the call being expanded is written in ( |
⎕C̲FG | Truthy a => Char -> a | Whether a configuration fact holds: the platform (cli or web) or a flag set with |
⎕G̲RID | Eq a => a -> Char | An array as a picture, returned as SVG text: a vector as one row of cells, a matrix as a grid, a rank-3 array as frames shown in turn. Numbers that are all 0 or 1 draw their 1s dark; other numbers are colored from the least (dark purple) to the greatest (yellow); characters are drawn in their cells. A frame of more than 64 by 64 numbers is drawn as an image, a pixel per cell. |
⎕P̲ATH | Num a => a -> Char | Points as a picture, returned as SVG text: 2 rows, x over y, joined in order and fitted into a 400-pixel picture with y pointing up; a rank-3 array is frames of paths shown in turn. |
⎕S̲HOW | Char -> Char | Show a picture, and return it: the command line writes it to a numbered file ( |
s̲hape | a -> Int | The length of each axis. |
t̲ally | a -> Int | How many items along the first axis: the rows of a matrix. With a subscript it counts along that axis only when the result keeps a rank the rule allows: |
r̲ange | Int -> Int | The numbers 1 to n. |
o̲ffsets | Int -> Int | The numbers 0 to n - 1. |
f̲irst | a -> a | The first item along the first axis: the first row. With a subscript, along that axis: |
r̲avel | a -> a | Every item as one vector, row after row. With axis 2, column after column. |
r̲eshape | Int -> a -> a | The items of the right argument, taken in order and repeated as needed, into the shape on the left. |
t̲ake | Int -> a -> a | The first n items (the last n for a negative n) along the first axis, or along the subscript's axis. |
d̲rop | Int -> a -> a | All but the first n items (the last n for a negative n), along the first axis or the subscript's. |
s̲elect | Int -> a -> a | The items at the given positions (from 1) along the first axis, or along the subscript's axis. |
r̲eplicate | Truthy a => a -> b -> b | Replicate: each item (each row of a matrix) repeated as many times as its count on the left, so a 0 drops it and a mask of 1s and 0s keeps the items where it is 1; one count extends to every item, and with a subscript the counts go along that axis. A negative count is an error. |
c̲at | a -> a -> a | Join along the first axis, or with a subscript along that axis of both arguments: |
r̲/ | (a -> a -> a) -> a -> a | Reduce: combine the items along the first axis with the function, from the right ( |
s̲\ | (a -> a -> a) -> a -> a | Scan: every running reduce, the last being the whole reduce. On a matrix down the rows; with a subscript along that axis. |
e̲ach | (a -> b) -> a -> b | Apply a function to every item. Given a dyadic function it pairs items of two arrays. |
m̲ap | (a -> b) -> a -> Box b | Map: the function on each item, every result boxed, so the function may give an array (e_ach wants one value per item). |
t̲able | (a -> b -> c) -> a -> b -> c | Every pairing of an item on the left with one on the right (APL's outer product): the result has both shapes. |
i̲nner | (a -> b -> c) -> (c -> c -> c) -> a -> b -> c | Inner product: |
c̲ompose | (a -> b) -> (b -> c) -> a -> c |
|
s̲wap | (a -> b -> c) -> b -> a -> c |
|
p̲ower | (a -> a) -> Int -> a -> a |
|
i̲ndexOf | Eq a => a -> a -> Int | Where each item of the right argument is first found among the items of the left, from 1; one past the end when it is not there. |
m̲ember? | (Eq a, Truthy b) => a -> a -> b | Whether each item of the left is among the items of the right. |
m̲atch | (Eq a, Truthy b) => a -> a -> b | Whether both sides have the same shape and equal items (APL's match): one result for the whole arrays, where |
u̲nique | Eq a => a -> a | The items without repeats, in first-seen order. |
s̲ort | Ord a => a -> a | The items in ascending order (the rows of a matrix, compared in order); with a subscript, sorted along that axis. |
g̲rade | Ord a => a -> Int | The positions that would sort the items: |
w̲here | Truthy a => a -> Int | The positions of the 1s in a vector. |
e̲nclose | a -> Box a | Enclose: the whole value as one item, a box, so arrays can be items of other arrays; a strand of strings encloses each string. A nested array prints in frames, as APL2's DISPLAY draws them (shown here as |
d̲isclose | Box a -> a | Disclose: what a box holds. It opens one box (select one item first). |
d̲isplay | a -> Char | Display: any value as APL2's DISPLAY draws it, as a character matrix, flat arrays framed too: an arrow along the top, a down arrow for each leading axis, and a mark at the bottom for what it holds ( |
p̲artition | Truthy a => a -> b -> Box b | Partition: the items (rows of a matrix) cut into pieces by the keys on the left, one per item: a new piece starts where the key goes up, and an item with key 0 is left out, so a mask of 1s and 0s cuts out the runs of 1s. Each piece is a box; one key extends to every item. |
e̲ncode | Int -> Int -> Int | Encode: the digits of a number in the radix on the left, most significant first (APL's encode). Radixes may differ from digit to digit (hours, minutes, seconds), a radix of 0 takes all that is left, and digits beyond the radix are dropped. A vector gives one column of digits per item. |
d̲ecode | Num a => a -> a -> a | Decode: the number whose digits, in the radix on the left, are on the right (APL's decode), the inverse of |
r̲ev | a -> a | Reverse the order of the items along the first axis (the rows of a matrix), or along the subscript's axis. |
o̲- | Int -> a -> a | Rotate: shift the items round by n (APL's rotate); positive n moves items toward the front. Along the first axis by default, so a matrix's rows move; with a subscript along that axis. A list of amounts gives one result per amount. |
o̲\ | a -> a | Transpose: reverse the order of the axes, so a matrix's rows become its columns; a vector or a single value is unchanged. A subscript of two axes swaps just those two. |
t̲ranspose | Int -> a -> a | Permute the axes: the left argument lists each axis once, and axis i of the right argument becomes the axis that item i of the list names (APL's dyadic transpose), so |