List of operators
Operators are listed in ASCII order. See also the operator precedence chart.
Meta-operators
The following operators change the way other operators are used, when applied on them.
$
Fold, \$
Scan: occur before a binary operator; the resulting compound operator is unary, with the same precedence as the original binary operator
*
Map: occurs after a unary operator; arity and precedence remain the same
:
Modify-assign: occurs after a unary, binary, or ternary operator; the resulting compound operator has the same arity but is right-associative and has the same precedence as :
Operators
!a
Logical not
a!=b
Numeric not equal
#a
Length
a#<b
Length less than
a#=b
Length equal
a#>b
Length greater than
a%b
Modulo
%a
Modulo 2
a&b
Logical and (short-circuiting)
a*b
Multiplication; if one operand is a Pattern, regex repetition
a**b
Alias for binary E
**a
Alias for unary E
a+b
Addition; if both operands are Patterns, regex concatenation
+a
Cast Scalar as number; with Pattern, repeat regex 1 or more times
++a
Increment (always comes before operand, never a++
); higher-precedence version of U
a,b
Range; if both operands are Patterns, regex alternation
,a
Range from 0 up to; set multiline flag on Pattern
a-b
Subtraction
-a
Numeric negation; set case-insensitive flag on Pattern
--a
Decrement (always comes before operand, never a--
); higher-precedence version of D
a.b
Concatenation
.a
Set dotall flag on Pattern; no-op on other data types
a/b
Division
/a
Reciprocal
a//b
Integer division
a:b
Assign b
to a
; if a
is a list of lvalues, pair them with values from b
and assign one by one (destructuring assignment)
a::b
Swap values of a
and b
(supports destructuring assignment); expression evaluates to (new value of) a
a<b
Numeric less than
a<=b
Numeric less than or equal
a<>b
Group iterable a
into sections of length b
; with negative b
, groups right-to-left
<>a
Group iterable a
into sections of length 2
a<|b
Strip characters in b
from right of a
<|a
Strip whitespace from right of a
a=b
Numeric equal
a==b
Exactly equal
a>b
Numeric greater than
a>=b
Numeric greater than or equal
a>|b
Round a
up to smallest multiple of b
that is >= a
>|a
Round a
up to smallest integer that is >= a
(ceil)
a?bc
Ternary If operator (short-circuiting)
a@b
Get item/slice at index
@a
Get item at index 0
a@*b
Find all indices of item b
in a
(find Scalar in Range, Pattern match or Scalar substring in Scalar, or any type in List)
a@<b
Slice of iterable left of index b
@<a
Slice of iterable left of index -1 (i.e. all but the last item)
a@>b
Slice of iterable right of index b
@>a
Slice of iterable right of index 0 (i.e. all but the first item)
a@?b
Find first index of item b
in a
(find Scalar in Range, Pattern match or Scalar substring in Scalar, or any type in List)
Aa
Convert first char of Scalar to ASCII value (or Unicode point); set ASCII-only flag on Pattern
ABa
Absolute value of number
aADb
Absolute difference (i.e. absolute value of the difference) of two numbers
aAEb
List a
with element b
appended
aALb
List a
with List b
appended
aATb
Arctan2 (with a
being the y-coordinate and b
being the x-coordinate)
ATa
Arctangent
aBAb
Bitwise and
BLa
Bitlength
aBNb
Bitwise not
aBOb
Bitwise or
aBXb
Bitwise xor
Ca
Convert ASCII value/Unicode point to character
aCBb
List of all combinations of b
elements from iterable a
aCGb
Coordinate grid of a
rows by b
columns ([0 0]
to [a b]
)
CGa
Coordinate grid of a
rows by a
columns ([0 0]
to [a a]
)
aCHb
Chop iterable a
into b
pieces of roughly equal length
CHa
Chop iterable a
into 2 pieces of roughly equal length
aCMb
Numeric comparison (-1 if a < b
, 0 if a = b
, 1 if a > b
)
COa
Cosine
aCPb
Cartesian product of two iterables
CPa
Cartesian product of a List of iterables
CSa
Cosecant
CTa
Cotangent
Da
Decrement (modifying argument in-place)
DBa
Double: a
times 2
aDCb
Delete all occurrences of characters in Scalar b
from Scalar a
DGa
Convert radians to degrees
aDKb
Sort iterable b
in descending order using Block a
as key function
DQa
Dequeue item from back of iterable (modifying argument in-place)
DNa
Sort iterable in descending order using numeric comparison
DSa
Sort iterable in descending order using string comparison
aEb
Exponentiation
Ea
Exponentiation with base 2
aEEb
E notation: a
times 10 to the power of b
EEa
Unary E notation: 10 to the power of a
ENa
Enumerate an iterable (gives List of [index item]
Lists)
EXa
Exponential (base e)
EYa
Identity matrix (abbreviation from Matlab’s eye() function)
FAa
Flatten all levels of List/Range a
, resulting in a flat List
aFBb
Convert number from given base to decimal integer
FBa
Convert number from binary to decimal integer
aFDb
Convert iterable containing digits in given base to decimal integer
FDa
Convert iterable containing digits in binary to decimal integer
aFEb
Filter-enumerate: keep items from iterable b
which return truthy results when function a
is called with the index and the item as arguments
aFIb
Filter: keep items from iterable b
which return truthy results when passed to function a
FIa
Unary filter: keep items from iterable a
which are truthy
aFJb
Filter iterable b
by Block a
and join results into Scalar
FJa
Keep items from iterable a
which are truthy and join results into Scalar
FLa
Flatten one level of List/Range a
(equivalent to $AL
)
aFNb
Filter negated: keep items from iterable b
which return falsey results when passed to function a
FNa
Unary filter negated: keep items from iterable a
which are falsey
aFUb
Filter-unpack: keep items from iterable b
which return truthy results when function a
is called with the item unpacked into zero or more function arguments
aFXb
Filter indexes: List of indexes into iterable b
which return truthy results when function a
is called with the index and the item as arguments
FXa
Unary filter indexes: List of indexes of truthy items in iterable a
aGTb
String greater than
aGEb
String greater than or equal
aHb
Get prefix of a
that is b
elements long (mnemonic: Head); with negative b
, get prefix of length len(a
)+b
Ha
Get prefix of a
containing all but the last element of a
HUa
Halve up: a
divided by 2 and rounded up
HVa
Halve: a
divided by 2 and rounded down
ICa
Convert to initial caps (capitalize the first character: aB Cd
-> Ab cd
)
aJb
Join iterable on separator
Ja
Join iterable on empty string
aJWb
Join iterable on separator and wrap result in separator as well
Ka
Apply Kleene star (repeat 0 or more times) to a Pattern
LBa
Binary logarithm (log base 2)
LCa
Convert to lowercase (aB Cd
-> ab cd
)
LDa
Decimal logarithm (log base 10)
aLEb
String less than or equal
LNa
Natural logarithm (log base e)
aLTb
String less than
aMb
Map Block a
to iterable b
, returning List
Ma
Maximum of iterable, using numeric comparison
aMCb
Map Block a
to each x,y in b
xb
grid of coordinate pairs; if b
is a two-element Range or List of Scalars, map to b@0
xb@1
grid
aMEb
Map Block a
to index/value pairs for items in iterable b
, returning List
aMFb
Map Block a
to iterable b
and flatten results by one level
aMJb
Map Block a
to iterable b
and join results into Scalar
aMMb
Map Block a
to each subitem of iterable b
, returning List of Lists
MNa
Alias for unary N
aMPb
Map Block a
to consecutive pairs of items from iterable b
, returning List
aMRbc
Map Block a
to each regex match of Pattern b
in Scalar c
(operands are rearrangeable)
aMSb
Map Block a
to iterable b
and sum results
aMUb
Map Block a
to iterable b
, unpacking each item as function arguments (like Python’s itertools.starmap
); returns List
MXa
Alias for unary M
aMZbc
Map Block a
to two iterables, passing zipped pairs of elements as arguments; returns List
aNb
In (returns count of occurrences or 0 if none)
Na
Minimum of iterable, using numeric comparison
aNEb
String not equal
aNIb
Not in (returns truth value 0 or 1)
Oa
Output value and pass through unchanged (same as P
but without trailing newline)
aOGb
Grid of ones (a
rows by b
columns)
OGa
Grid of ones (a
rows by a
columns)
Pa
Print value with newline and pass through unchanged (output format for Lists depends on command-line flags; nil gives no output and also suppresses trailing newline)
aPBb
Push item to back of iterable (modifying argument in-place)
aPEb
List a
with element b
prepended
PMa
List of all permutations of iterable
aPKb
Pick out item from index b
of iterable a
(modifying a
in-place)
POa
Pop item from front of iterable (modifying argument in-place)
aPUb
Push item to front of iterable (modifying argument in-place)
PZa
Palindromize iterable, appending its reverse but without repeating the central item
aQb
String equal
QPa
Quad-palindromize iterable, palindromizing it and also each of its items
QRa
Quad-reflect iterable, reflecting it and also each of its items
aRbc
Replace each occurrence in Scalar a
of substring or Pattern b
with replacement c
Ra
Reverse
aRAbc
Replace item in iterable a
at index b
with replacement c
RCa
Uniformly random choice of single item from iterable
RDa
Convert degrees to radians
REa
Call the current function recursively with argument a
RFa
Reflect iterable, appending its reverse
aRLb
Repeat List a
b
times
aRMb
Remove occurrences of b
from a
(removes items from List or Range; removes substrings or regex matches from Scalar)
aRNb
Round a
to nearest multiple of b
RNa
Round a
to nearest integer
RPa
Like Python’s repr
: convert to an unambiguous string representation (numeric Scalar becomes 123.45
; non-numeric Scalar becomes "abc"
; Pattern becomes `abc`
; Range becomes (1,4)
; List becomes [1;2;"three"]
; Nil becomes ()
)
aRRb
Random integer in range from a
to b
RRa
Random integer in range from 0 to a
aRTb
a
th root of b
RTa
Square root of a
RVa
Alias for unary R
aRZb
Round a
to next multiple of b
closer to zero
RZa
Round a
to next integer closer to zero (truncate)
aSb
Get suffix of a
that is b
elements long; with negative b
, get suffix of length len(a
)+b
Sa
Get suffix of a
containing all but the first element of a
SCa
Swap case: Hello, World!
becomes hELLO, wORLD!
SEa
Secant
SGa
Sign of number (-1, 0, or 1)
SHa
Shuffle: random permutation of iterable
SIa
Sine
aSKb
Sort iterable b
using Block a
as key function
SNa
Sort iterable in ascending order using numeric comparison
SQa
a
squared
SSa
Sort iterable in ascending order using string comparison
STa
Convert to string (for Lists, the format of the result depends on command-line flags)
TAa
Tangent
aTBb
Convert decimal integer a
to base b
TBa
Convert decimal integer a
to binary
TCa
Convert to title case (aB Cd
-> Ab Cd
)
aTDb
Convert decimal integer a
to list of digits in base b
TDa
Convert decimal integer a
to list of digits in binary
aTMb
Trim Scalar a
by b
characters from front and end (Scalar b
trims same amount on both sides; Range b
trims different amounts)
TMa
Trim first and last characters from Scalar a
aTRbc
Transliterate a
from characters in b
to those in c
(with b
or c
Scalar, transliterates one letter to another; with b
or c
Range or List of numbers, translates character codes)
Ua
Increment (modifying argument in-place)
UCa
Convert to uppercase (aB Cd
-> AB CD
)
UQa
Keep only unique values from iterable
aUWb
Unweave iterable a
into a List of b
strands
UWa
Unweave iterable a
into a List of two strands
aVb
Call Block as function with arglist (equivalent to a(*b)
in Python)
Va
Evaluate Block in current context, returning value of final expression or nil if there isn’t one
aWRb
Wrap Scalar or Pattern with a delimiter
aWVb
Weave two iterables together, alternating their items
WVa
Weave all subitems in an iterable together
aXb
Repeat Scalar a
b
times
Xa
Covert Scalar or List/Range to equivalent regex Pattern (escaping special characters as necessary)
Ya
Yank value into the variable y
(equivalent to (y:a)
)
YOa
Output value, then yank it (equivalent to (y:Oa)
)
YPa
Print value, then yank it (equivalent to (y:Pa)
)
aZb
Zip two Lists together (clipping to the shorter length)
Za
Zip a List of Lists together (clipping to the shortest length)
aZDb
Zip a List of Lists together, filling missing values with default value b
ZDa
Zip a List of Lists together, filling missing values with default value ""
aZGb
Grid of zeros (a
rows by b
columns)
ZGa
Grid of zeros (a
rows by a
columns)
aZJb
Zip two iterables together, filling missing values with " "
, and join each pair of values into a string
ZJa
Zip a List of iterables together, filling missing values with " "
, and join each group of values into a string
\!a
Logical not (can be used in lambda expressions)
a\&b
Logical and (non-short-circuiting, can be used in lambda expressions)
a\,b
Inclusive range
\,a
Inclusive range from 1
a\?bc
If-then-else operator (non-short-circuiting, can be used in lambda expressions)
a\|b
Logical or (non-short-circuiting, can be used in lambda expressions)
a^b
Split Scalar a
on separator b
^a
Split Scalar a
into List of characters
a^@b
Split iterable a
at index or List of indices b
a|b
Logical or (short-circuiting)
a|<b
Round a
down to largest multiple of b
that is <= a
|<a
Round a
down to largest integer that is <= a
(floor)
a|>b
Strip characters in b
from left of a
|>a
Strip whitespace from left of a
a||b
Strip characters in b
from a
||a
Strip whitespace from a
a~b
Find first regex match of b
in Scalar a
(reversible)
a~=b
Test if Pattern b
fully matches Scalar a
(reversible)