В алфавите языка
APL около 70 спецсимволов!
Примеры программ
life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}
Игра Жизнь
(~R∊R∘.×R)/R←1↓ιR
Все простые число от 1 до R
Monadic functions[edit]
Name(s) |
Notation |
Meaning |
Roll |
?B |
One
integer selected randomly from the first B integers |
⌈B |
Least
integer greater than or equal to B |
|
⌊B |
Greatest
integer less than or equal to B |
|
Shape, Rho |
⍴B |
Number
of components in each dimension of B |
∼B |
Logical: ∼1 is 0, ∼0 is 1 |
|
∣B |
Magnitude of B |
|
Index generator, Iota |
⍳B |
Vector
of the first B integers |
⋆B |
e
to the B power |
|
−B |
Changes sign of B |
|
+B |
No change to B |
|
×B |
¯1 if B<0; 0 if B=0; 1 if B>0 |
|
÷B |
1 divided by B |
|
Ravel, Catenate, Laminate |
,B |
Reshapes B into
a vector |
Matrix inverse, Monadic Quad Divide |
⌹B |
Inverse of matrix B |
Pi times |
○B |
Multiply by π |
⍟B |
Natural logarithm of B |
|
Reversal |
⌽B |
Reverse
elements of B along last axis |
Reversal |
⊖B |
Reverse
elements of B along first axis |
Grade up |
⍋B |
Indices
of B which will arrange B in ascending
order |
Grade down |
⍒B |
Indices
of B which will arrange B in descending
order |
⍎B |
Execute an APL expression |
|
Monadic format |
⍕B |
A
character representation of B |
Monadic transpose |
⍉B |
Reverse
the axes of B |
!B |
Product
of integers 1 to B |
Dyadic functions[edit]
Name(s) |
Notation |
Meaning |
A+B |
Sum
of A and B |
|
A−B |
A minus B |
|
A×B |
A multiplied by B |
|
A÷B |
A divided by B |
|
A⋆B |
A raised
to the B power |
|
Circle |
A○B |
Trigonometric
functions of B selected by A A=1: sin(B) A=5: sinh(B) A=2: cos(B) A=6: cosh(B) A=3: tan(B) A=7: tanh(B) Negatives
produce the inverse of the respective functions |
Deal |
A?B |
A distinct integers selected randomly from the
first B integers |
Membership, Epsilon |
A∈B |
1 for elements of A present
in B; 0 where not. |
Maximum, Ceiling |
A⌈B |
The greater value of A or B |
Minimum, Floor |
A⌊B |
The smaller value of A or B |
Reshape, Dyadic Rho |
A⍴B |
Array of shape A with
data B |
Take |
A↑B |
Select the first (or last) A elements
of B according to ×A |
Drop |
A↓B |
Remove the first (or last) A elements
of B according to ×A |
Decode |
A⊥B |
Value of a polynomial whose coefficients
are B at A |
Encode |
A⊤B |
Base-A representation of the
value of B |
A∣B |
B modulo A |
|
Catenation |
A,B |
Elements of B appended
to the elements of A |
Expansion, Dyadic Backslash |
A\B |
Insert zeros (or blanks) in B corresponding
to zeros in A |
Compression, Dyadic Slash |
A/B |
Select elements in B corresponding
to ones in A |
Index of, Dyadic Iota |
A⍳B |
The location (index) of B in A; 1+⍴A if
not found |
Matrix divide, Dyadic Quad Divide |
A⌹B |
Solution to system of
linear equations, multiple
regression Ax
= B |
Rotation |
A⌽B |
The elements of B are
rotated A positions |
Rotation |
A⊖B |
The elements of B are
rotated A positions along the first axis |
A⍟B |
Logarithm of B to
base A |
|
Dyadic format |
A⍕B |
Format B into a
character matrix according to A |
General transpose |
A⍉B |
The axes of B are
ordered by A |
Combinations |
A!B |
Number of combinations of B taken A at
a time |
Diaeresis, Dieresis, Double-Dot |
A¨B |
Over each, or perform each
separately; B = on these; A = operation to
perform or using(e.g. iota) |
Less than |
A<B |
Comparison: 1 if true, 0 if false |
Less than or equal |
A≤B |
Comparison: 1 if true, 0 if false |
A=B |
Comparison: 1 if true, 0 if false |
|
Greater than or equal |
A≥B |
Comparison: 1 if true, 0 if false |
Greater than |
A>B |
Comparison: 1 if true, 0 if false |
Not equal |
A≠B |
Comparison: 1 if true, 0 if false |
A∨B |
Boolean Logic: 0(False)
if both A and B = 0,
1 otherwise. Alt: 1(True) if A or B = 1(True) |
|
A∧B |
Boolean Logic: 1(True)
if both A and B = 1,
0(False) otherwise |
|
A⍱B |
Boolean Logic: 1 if both A and B are 0, otherwise 0. Alt: ~∨ = not Or |
|
A⍲B |
Boolean Logic: 0 if both A and B are 1, otherwise 1. Alt: ~∧ = not And |
Operators
and axis indicator[edit]
Name(s) |
Symbol |
Example |
Meaning (of example) |
Reduce (last axis), Slash |
/ |
+/B |
Sum across B |
Reduce (first axis) |
⌿ |
+⌿B |
Sum down B |
Scan (last axis), Backslash |
\ |
+\B |
Running sum across B |
Scan (first axis) |
⍀ |
+⍀B |
Running sum down B |
Inner product |
. |
A+.×B |
Matrix product of A and B |
Outer product |
∘. |
A∘.×B |
Outer product of A and B |