Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Functions

Victor Dumbrava edited this page Nov 1, 2017 · 16 revisions

Functions operate on data, which can either be an argument or the result of another function.

Single Byte Nilads

Character Function
® Retrieve the value from the register
³ First input (third command line argument) or 100
Second input (fourth command line argument) or 16
Third input (fifth command line argument) or 10
Fourth input (sixth command line argument) or " "
Fifth input (seventh command line argument) or "\n"
Sixth input (eighth command line argument) or []
Seventh input (ninth command line argument) or 256
Left Argument or 0.1
Right Argument or 1 (TODO)
π Pi

Single Byte Monads

Character Function
~ Bitwise NOT
Square Root
Decrement
Increment
¹ Identity
² Square
! Factorial(z) if z is a nonnegative integer, -Factorial(abs(z)) if z is a negative integer, Gamma(z + 1) otherwise
A Absolute Value
B Convert integer to binary
Convert binary to integer
D Convert integer to decimal
List Partitions
Convert decimal to integer
E 1 if all elements are equal, otherwise 0
Ė Enumerate; returns [[1, z[1]], [2, z[2]], ...]
F Flatten list completely
G Format as a grid
H Convert integer to hexadecimal
Pop and return the first value of a list
Convert hexadecimal to integer
İ Inverse; 1 / z for integers and upside-down (wherever applicable) for characters
J Range of length (range(len(z)))
L Length
Lowered Range; 0 .. z - 1
Logical NOT; does not vectorize
P Product
Permutations
R Range; 1 .. z
S Sum
Sort a list
Sign of a real number or conjugate of a complex number
T Indices of truthy elements
Pop and return the last value of a list
Return an array of 1 and 0 with 1 at the indices of z
U Return the unique elements of z in order by their first occurrence
W Wrap; return [z]
Sublists; return all contiguous subslices of z
X Random element of a list, random integer in the range 1 .. z if z is an integer, random float from 0 to z if z is a float
Tighten; flatten by 1 level
Z Integer Partitions; all lists of positive integers that sum to z
Deltas; return differences of consecutive pairs
Reverse each sublist to the last level
Reverse a list; does not vectorize
¬ Logical NOT; vectorizes
Transpose a matrix
Anti-transpose a matrix
Rotate a matrix by 90 degrees
Rotate a matrix by -90 degrees
Rotate a matrix by 180 degrees
Prefixes
Suffixes

Single Byte Dyads

Character Function
_ Subtraction
+ Addition
± [x + y, x - y]
* Exponentiation
× Multiplication
÷ Floating-Point Division
: Integer Division
% Modulus
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
< Less-than
Less-than or equal
= Equals; does not vectorize
e Equals; vectorizes
Similar; same length if lists, within 1 of each other if numbers
n Not Equals; vectorizes
Not Equals; does not vectorize
Greater-than or equal
> Greater-than
» Maximum
« Minimum
, Pair; return [x, y]
; Concatenate/Append
· Dot Product
Rotate rows left
Rotate rows right
Rotate left; does not vectorize
Rotate right; does not vectorize
b Convert x to base y
Convert x to bijective base y
ċ Combinations of x with y elements
ė 1 if x is an element of y, otherwise 0
0 if x is an element of y, otherwise 1
g GCD
Head; get first y elements of x
Head; get all but last y elements of x
j Join x with separator y
l LCM
m Modular; get every yth element of x. Append to its reverse if y is 0
Mold; shape the contents of x like y. Repeats elements of x if necessary
r Range [x, y]
Range (x, y)
Range [x, y)
s Slice x into lists of length y
Return overlapping slices of length y of x
ŝ Slice x into y lists of similar length
Split x at occurrences of y
Tail; get all but first y elements of x
Tail; get last y elements of x
Flatten x by y layers
z Zip x with filler y
ż Zip; Interleave x with y
Zip x with y

Assorted Nilads (Ø)

Character Function
ØX Random float in the range [0, 1)

Assorted Monads (Æ)

Character Function
ÆC Count primes up to (including) z
ÆĊ Count composites up to (including) z
ÆR Inclusive Prime Range
ÆS Sine
ÆṢ Arcsine
ÆT Tangent
ÆṬ Arctangent
ÆA Cosine
ÆẠ Arccosine
Æs Sinh
Æṣ Arcsinh
Æa Cosh
Æạ Arccosh
Æt Tanh
Æṭ Arctanh
ÆṪ Totient
ÆU Remove adjacent equal elements
ÆI 1 if z is an integer else 0
Æṁ Median
Æṃ Mode
Æm Arithmetic Mean
Æ∆ zth triangular number
Æσ Standard Deviation
Æ√ Integer Square Root

Assorted Monads (Œ)

Character Function
ŒB Bounce; yield z[:-1] + z[::-1]. Vectorizes to layer 1
ŒḄ Bounce; yield z[:-1] + z[::-1]. Does not vectorize
ŒD Matrix Diagonals. Starts from the small diagonal in the bottom left corner
ŒḊ Matrix Antidiagonals. Starts from the small diagonal in the bottom right corner
ŒḌ Reconstruct a matrix from its diagonals; diagonals can be in any rotation but must be in the right order
ŒM Matrix Diagonals. Starts with the main diagonal
ŒṀ Matrix Antidiagonals. Starts with the main antidiagonal
Œ_ Yield [] given an argument. Suppresses output
ŒT Count the number of truthy elements
ŒṖ Powerset
Œg Group equal elements
Œr Run-Length Encode
Œṙ Run-Length Decode
Œ√ 1 if z is a perfect square else 0

Assorted Dyads (æ)

Character Function
æ← Cyclic Predecessor of element x in y
æ→ Cyclic Successor of element x in y
æ« Left Bit-Shift; x * 2 ^ y
æ» Right Bit-Shift; x * 2 ^ -y; returns an integer
æ√ General Root; x ^ (1 / y)
æx Random integer in the range [x, y]

Assorted Dyads (œ)

Character Function
œc Choose; nCr
œp Pick; nPr
œ← Cyclic Predecessor of sublist x in y
œ→ Cyclic Successor of sublist x in y
œx Random float in the range [x, y)
œḷ Left Argument; x
œṛ Right Argument; y