Complex Conjugate | +X | +23 0 ¯31 1J1 ⇔ | Add | A+B | 75 3 46 + 5 ¯2 8 ⇔ 80 1 54 | |
Negate | -X | -1 ¯17 44.8 ⇔ ¯1 17 ¯44.8 | Subtract | A-B | 75 3 46 - 5 ¯2 8 ⇔ 70 5 38 | |
Signum | ×X | ×56.2 ¯1.4 0 0J¯3 ⇔ 1 ¯1 0 0J¯1 | Multiply | A×B | 75 3 46 × 5 ¯2 8 ⇔ 375 ¯6 368 | |
Reciprocal | ÷X | ÷1 2 3 4 ⇔ 1 0.5 0.3333333333 0.25 | Divide | A÷B | 75 3 46 ÷ 5 ¯2 8 ⇔ 15 ¯1.5 5.75 | |
Magnitude | |X | |23 0 ¯31 1J1 ⇔ 23 0 31 1.414213562 | Residue (Remainder) | A|B | 3|15.4 ¯21 ¯23 9 8 ⇔ 0.4 0 1 0 2 | |
Exponential (eX) | *X | *1 2 ⇔ 2.718281828 7.389056099 | Power | A*B | 3 7 16 * 3 2 0.5 ⇔ 27 49 4 | |
Natural Logarithm | ⍟X | ⍟2.718281828 10 ⇔ 1 2.302585093 | Logarithm (Base A ) | A⍟B | 2⍟1023 ⇔ 9.99859043 | |
Ceiling | ⌈X | ⌈ ¯2.8 ¯1.1 0 1.1 2.5 ⇔ ¯2 ¯1 0 2 3 | Maximum | A⌈B | 4 17 ¯2 ⌈ 3 64.8 1 ⇔ 4 64.8 1 | |
Floor | ⌊X | ⌊ ¯2.8 ¯1.1 0 1.1 2.5 ⇔ ¯3 ¯2 0 1 2 | Minimum | A⌊B | 4 17 ¯2 ⌊ 3 64.8 1 ⇔ 3 17 ¯2 | |
Factorial | !X | !14 ⇔ 87178291200 | Binomial Coefficient | A!B | Number of combinations of B items taken A at a time | |
Pi Times | ○X | ○÷180 ⇔ 0.01745329252 | Circular Functions | A○B | See table below | |
Roll | ?X | Randomly choose an item from ⍳X | Deal | A?B | Randomly choose A items from ⍳B without replacement | |
Base Value | A⊥B | 2⊥0 1 0 0 0 1 ⇔ 17 | ||||
Representation | A⊤B | 2 2 2 2 2 2 ⊤ 17 ⇔ 0 1 0 0 0 1 | ||||
Grade Up | ⍋X | List of indices that will sort X in ascending order | Grade Up | A⍋B | Alphabetic sort: A gives the collating sequence | |
Grade Down | ⍒X | List of indices that will sort X in descending order | Grade Down | A⍒B | Alphabetic sort: A gives the collating sequence | |
Matrix Inverse | ⌹X |
| Matrix Divide | A⌹B | Multiply A by the inverse of matrix B | |
Execute | ⍎X | Evaluate APL2 expression given as character vector X |
|
| ||
Format | ⍕X | ⍕¯17.5 ⇔ '¯17.5' | Format | A⍕B | 0 3 4 0 6 ¯2⍕ ¯12.14 30 17.1 ⇔ '¯12.140 30 1.7E1' '06/06/0006' ⍕ 7 20 1969 ⇔ '07/20/1969' | |
Expand | A\B | 1 0 0 1 1 0 1\3 1 4 2 ⇔ 3 0 0 1 4 0 2 | ||||
Expand | A⍀B | Expand along the first axis of B | ||||
Replicate | A/B | 2 0 ¯5 3 1/3 1 4 2 ⇔ 3 3 0 0 0 0 0 4 4 4 2 | ||||
Replicate | A⌿B | Replicate along the first axis of B |
Less Than | A<B | 1 2 3 < 3 2 1 ⇔ 1 0 0 |
Less Than or Equal To | A≤B | 1 2 3 ≤ 3 2 1 ⇔ 1 1 0 |
Equal To | A=B | 1 2 3 = 3 2 1 ⇔ 0 1 0 |
Not Equal To | A≠B | 1 2 3 ≠ 3 2 1 ⇔ 1 0 1 |
Greater Than or Equal To | A≥B | 1 2 3 ≥ 3 2 1 ⇔ 0 1 1 |
Greater Than | A>B | 1 2 3 > 3 2 1 ⇔ 0 0 1 |
Not | ~X | ~0 1 ⇔ 1 0 |
And | A∧B | 1 1 0 0 ∧ 1 0 1 0 ⇔ 1 0 0 0 |
Or | A∨B | 1 1 0 0 ∨ 1 0 1 0 ⇔ 1 1 1 0 |
Nand | A⍲B | 1 1 0 0 ⍲ 1 0 1 0 ⇔ 0 1 1 1 |
Nor | A⍱B | 1 1 0 0 ⍱ 1 0 1 0 ⇔ 0 0 0 1 |
Match | A≡B | 1 if A and B have the same dimensions, nesting levels, and contents, 0 otherwise |
Membership | A∈B | 'ace'∈'A Programming Language' ⇔ 1 0 1 |
Find | A⍷B | 'ISSI'⍷'MISSISSIPPI' ⇔ 0 1 0 0 1 0 0 0 0 0 0 |
0○X | (1-X*2)*0.5 | 0○X | (1-X*2)*0.5 | |
1○X | Sine | ¯1○X | Arcsine | |
2○X | Cosine | ¯2○X | Arccosine | |
3○X | Tangent | ¯3○X | Arctangent | |
4○X | (1+X*2)*0.5 | ¯4○X | (¯1+X*2)*0.5 | |
5○X | Hyperbolic Sine | ¯5○X | Inverse Hyperbolic Sine | |
6○X | Hyperbolic Cosine | ¯6○X | Inverse Hyperbolic Cosine | |
7○X | Hyperbolic Tangent | ¯7○X | Inverse Hyperbolic Tangent | |
8○X | (¯1-X*2)*0.5 for X<0 -(¯1-X*2)*0.5 for X≥0 | ¯8○X | -8○X | |
9○X | Real part of X | ¯9○X | X | |
10○X | |X | ¯10○X | +X (complex conjugate) | |
11○X | Imaginary part of X | ¯11○X | 0J1×X | |
12○X | Phase of X | ¯12○X | *0J1×X |
Note: one way to get the arctangent of Y÷X in the proper quadrant (-π to +π) is 12○X+11○Y
Index | A⌷B | Select items from B using indices A | ||||
Index Generator | ⍳X | ⍳8 ⇔ 1 2 3 4 5 6 7 8 | Index Of | A⍳B | 'HELLO'⍳'ELP' ⇔ 2 3 6 | |
Not (see Boolean Functions) | Without | A~B | (⍳8)~1 4 5 ⇔ 2 3 6 7 8 | |||
Shape of | ρX | List of dimensions of X | Reshape | AρB | 3 4ρ'ABCDEFGHIJKL' ⇔ ABCD | |
Reverse | ⌽X | ⌽⍳8 ⇔ 8 7 6 5 4 3 2 1 | Rotate | A⌽B | 3⌽⍳8 ⇔ 4 5 6 7 8 1 2 3 | |
Reverse Vertically | ⊖X | ⊖3 4ρ'ABCDEFGHIJKL' ⇔ IJKL | Rotate Vertically | A⊖B | 1⊖3 4ρ'ABCDEFGHIJKL' ⇔ EFGH | |
Transpose | ⍉X | ⍉3 4ρ'ABCDEFGHIJKL' ⇔ AEI | Transpose | A⍉B | The elements of A give the new order for the axes of B | |
First | ↑X | The first element of X | Take | A↑B | ¯3↑⍳8 ⇔ 6 7 8 | |
Drop | A↓B | 3↓⍳8 ⇔ 4 5 6 7 8 | ||||
Enclose | ⊂X | Represent array X as a scalar | Partition | A⊂B | 1 0 1 1 2 2 2 3 ⊂ 'ABCDEFGH' ⇔┌→─────────────────┐ | |
Disclose | ⊃X | Remove one level of nesting from X | Pick | A⊃B | Indices A select an item from within nested array B | |
Depth | ≡X | Deepest level of nesting in X | Match (see Boolean Functions) | |||
Ravel | ,X | Change X to a vector, preserving depth | Catenate | A,B | Connect two arrays along their last axis | |
Enlist | ∈X | Change X to a vector of depth 1 | Membership (see Boolean Functions) |
Each | f¨X | Apply function f to each item of X |
Reduction | f/X | Apply function f along the last axis (rows) of X |
Reduction | f⌿X | Apply function f along the first axis of X |
N-Wise Reduction | A f/B | Apply function f along the last axis (rows) of B with a moving window of size A |
N-Wise Reduction | A f⌿B | Apply function f along the first axis of B with a moving window of size A |
Scan | f\X | Apply function f along the last axis (rows) of X , displaying intermediate results |
Scan | f⍀X | Apply function f along the first axis of X , displaying intermediate results |
Inner Product | A f.g B | Apply function g between rows of A and corresponding columns of B , then apply f along each result |
Outer Product | A ∘.f B | Apply function f between every combination of one element from A and one element from B |
Note: A+.×B
is the standard matrix multiplication operation for matrices A
and B
.
Scans of boolean vectors are often useful:
∧\X | Make everything 0 after the first 0 |
<\X | Make everything 0 after the first 1 |
≤\X | Make everything 1 after the first 0 |
∨\X | Make everything 1 after the first 1 |
X∨≠\X | Make everything 1 between odd and even 1s |