Uiua

Stack-based array programming language with a unique glyph-based syntax. Each built-in function is a single Unicode character. Code is written right-to-left. Runs in the browser via WebAssembly.

Core concepts

  • Stack-based: Functions consume from and push to an implicit stack
  • Array-oriented: All values are arrays; scalar = rank-0 array
  • Tacit/point-free: Functions compose without naming arguments
  • Glyphs: Built-ins are single Unicode chars (e.g. + add, reverse, shape)

Basic syntax

# Numbers push to the stack
1 2 3       # stack: [1, 2, 3]
 
# Add consumes two, pushes one
+ 1 2       # → 3
 
# Arrays
[1 2 3 4 5]
 
# String
"hello"
 
# Arithmetic (right-to-left reads as left-to-right math)
× 2 + 1 3   # (1 + 3) × 2 = 8

Common glyphs

Algorithm

NameGlyphArgsOutputsDescription
derivative1Calculate the derivative of a mathematical expression
fft11Run the Fast Fourier Transform on an array
geometric1Convert an operation to be in geometric algebra
hsv11Convert a color array from RGB to HSV
integral1Calculate an antiderivative of a mathematical expression
oklch11Convert a color array from RGB to Oklch
path2Find the shortest path between two things
recur1Execute a recursive or tree algorithm
regex21Match a regex pattern

Arguments

NameGlyphArgsOutputsDescription
above1Keep all arguments to a function before the outputs
backward˜1Call a function with its arguments swapped
below1Keep all arguments to a function after the outputs
both1Call a function on two sets of values
bracket1Call two functions on two distinct sets of values
by1Call a function but keep its last argument after its outputs
dip1Skip the first argument and call a function on later arguments
duplicate.12Duplicate the top value on the stack
flip:22Swap the top two values on the stack
fork1Call two functions on the same values
gap1Discard the first argument then call a function
identity11Do nothing with one value
off1Call a function but keep its first argument after its outputs
old reach𝄐1Old reach
on1Call a function but keep its first argument before its outputs
pop10Discard the first argument
reach1Call a function skipping the second argument
self˙1Call a function with the same array as all arguments
with1Call a function but keep its last argument before its outputs

Command

NameGlyphArgsOutputsDescription
&invk10Invoke a path with the system’s default program
&runc13Run a command and wait for it to finish
&runi11Run a command and wait for it to finish
&runs13Run a command with streaming IO

Comptime

NameGlyphArgsOutputsDescription
comptime1Run a function at compile time
quote01Convert a string into code at compile time

Constant

NameGlyphArgsOutputsDescription
etaη01The number of radians in a quarter circle
infinity01The biggest number
piπ01The ratio of a circle’s circumference to its diameter
tauτ01The ratio of a circle’s circumference to its radius

Debug

NameGlyphArgsOutputsDescription
args?00Debug print all arguments without consuming them
dump00Preprocess and print all arguments without popping them

DyadicArray

NameGlyphArgsOutputsDescription
base21Get the base digits of a number
couple21Combine two arrays as rows of a new array
drop21Drop the first n rows of an array
find21Find the occurrences of one array in another
indexin21Find the first index in an array of each row of another array
indexof21Find the first index of each row of one array in another
join21Append two arrays end-to-end
keep21Discard or copy some rows of an array
mask21Mask the occurrences of one array in another
match21Check if two arrays are exactly the same
memberof21Check if each row of one array exists in another
orient21Change the order of the axes of an array
pick21Index a row or elements from an array
rerank21Change the rank of an array’s rows
reshape21Change the shape of an array
rotate21Rotate the elements of an array by n
select21Select multiple rows from an array
take21Take the first n rows of an array
windows21The n-wise windows of an array

DyadicPervasive

NameGlyphArgsOutputsDescription
add+21Add values
atangent21Take the arctangent of two numbers
complex21Make a complex number
divide÷21Divide values
equals=21Compare for equality
greater or equal21Compare for greater than or equal
greater than>21Compare for greater than
less or equal21Compare for less than or equal
less than<21Compare for less than
maximum21Take the maximum of two arrays
minimum21Take the minimum of two arrays
modulo21Modulo values
multiply×21Multiply values
not equals21Compare for inequality
or21Logical OR and greatest common divisor
power21Raise a value to a power
subtract-21Subtract values

Encoding

NameGlyphArgsOutputsDescription
apng21Encode an array of image frames in an APNG-encoded byte array
audio31Encode audio into a byte array
binary11Encode an array into a compact binary representation
bytes21Convert a value to a byte representation
compress21Compress bytes according to some algorithm
csv11Encode an array into a CSV string
gif21Encode an array of image frames in a GIF-encoded byte array
graphemes11Convert a string to a list of UTF-8 grapheme clusters
img21Encode an image into a byte array with the specified format
json11Encode an array into a JSON string
layout21Render text into an image array
parse11Parse a string as a number
utf₈11Convert a string to UTF-8 bytes
voxels11Project a voxel array to an image
xlsx11Encode an array into XLSX bytes

Env

NameGlyphArgsOutputsDescription
&args01Get the command line arguments
&raw10Set the terminal to raw mode
&ts01Get the size of the terminal
&var11Get the value of an environment variable

Environment

NameGlyphArgsOutputsDescription
arch01Get the current architecture
dllext01Get the DLL extension for the current platform
exeext01Get the executable extension for the current platform
numprocs01Get the number of processors on the current system
os01Get the current operating system
osfamily01Get the current operating system family
pathsep01Get the primary path separator for the current platform

Ffi

NameGlyphArgsOutputsDescription
&ffi21Call a foreign function interface
&malloc11Allocate memory for the given number of bytes and return a pointer to it
&memcpy21Copy data from a pointer into an array
&memfree10Free a pointer
&memset30Write data from an array into a pointer

Filesystem

NameGlyphArgsOutputsDescription
&cd10Change the current directory
&fc11Create a file and return a handle to it
&fde10Delete a file or directory
&fe11Check if a file, directory, or symlink exists at a path
&fif11Check if a path is a file
&fld11List the contents of a directory
&fmd10Create a directory
&fo11Open a file and return a handle to it
&frab11Read all the contents of a file into a byte array
&fras11Read all the contents of a file into a string
&ftr10Move a file or directory to the trash
&fwa20Write the entire contents of an array to a file

InversionModifier

NameGlyphArgsOutputsDescription
anti1Invert the behavior of a function, treating its first argument as a constant
obverse1Define the various inverses of a function
un°1Invert the behavior of a function
under1Operate on a transformed array, then reverse the transformation

IteratingModifier

NameGlyphArgsOutputsDescription
do1Repeat a function while a condition holds
fold1Apply a function to aggregate arrays
reduce/1Apply a reducing function to an array
repeat1Repeat a function a number of times
scan\11Reduce, but keep intermediate values

Map

NameGlyphArgsOutputsDescription
get21Get the value corresponding to a key in a map array
has21Check if a map array has a key
insert31Insert a key-value pair into a map array
map21Create a hashmap from a list of keys and list values
remove21Remove the value corresponding to a key from a map array

MappingModifier

NameGlyphArgsOutputsDescription
each1Apply a function to each element of an array or arrays
group1Group elements of an array into buckets by index
inventory1Apply a function to each unboxed row of an array and re-box the results
partition1Group sequential sections of an array
rows1Apply a function to each row of an array or arrays
stencil21Call a function on windows of an array
table1Apply a function to each combination of rows of some arrays
tuples1Get permutations or combinations of an array

Media

NameGlyphArgsOutputsDescription
&ap10Play some audio
&apngs20Show an APNG
&asr01Get the sample rate of the audio output backend
&ast00Synthesize and stream audio
&gifs20Show a gif
&ims10Show an image

Misc

NameGlyphArgsOutputsDescription
&b00Pause the execution and print the argument list
&camcap11Capture an image from a webcam
&camlist01List names of available webcams
&clip01Get the contents of the clipboard
&exit10Exit the program with a status code
&sl10Sleep for n seconds
assert20Throw an error if a condition is not met
case1Call a pattern matching case
pattern1Choose different cases based on pattern matching
pretty11Convert a value to its pretty-printed output representation
repr11Convert a value to its code representation
try1Call a function and catch errors
type11Check the type of an array

MonadicArray

NameGlyphArgsOutputsDescription
bits11Encode an array as bits (LSB-first)
box11Turn an array into a box
classify11Assign a unique index to each unique row in an array
deduplicate11Remove duplicate rows from an array
deshape11Make an array 1-dimensional
fall11Get the indices into an array if it were sorted descending
first11Get the first row of an array
fix¤11Add a length-1 axis to an array
last11Get the last row of an array
length11Get the number of rows in an array
occurrences11Mark each row of an array with its occurrence count
range11Make an array of all natural numbers less than a number
reverse11Reverse the rows of an array
rise11Get the indices into an array if it were sorted ascending
shape11Get the dimensions of an array
sort11Sort an array
transpose11Rotate the shape of an array
unique11Get a mask of first occurrences of items in an array
where11Get indices where array values are not equal to zero

MonadicPervasive

NameGlyphArgsOutputsDescription
absolute value11Get the absolute value of a number
ceiling11Round to the nearest integer towards ∞
exponential11Get the exponential of a number
floor11Round to the nearest integer towards ¯∞
negate¯11Negate a number
not¬11Logical not
reciprocal11Get the reciprocal of a number
round11Round to the nearest integer
sign±11Numerical sign (1, ¯1, or 0)
sine11Get the sine of a number
sqrt11Take the square root of a number

OtherModifier

NameGlyphArgsOutputsDescription
content1Unbox the arguments to a function before calling it
evert1Call a function with its arguments’ axes reversed
fill1Set the fill value for a function
memo1Memoize a function
switch1Call the function at the given index

RNG

NameGlyphArgsOutputsDescription
gen21Generate an array of random numbers with a seed
noise31Generate random noise
random01Generate a random number in the range [0, 1)

StdIO

NameGlyphArgsOutputsDescription
&ep10Print a value to stderr followed by a newline
&epf10Print a value to stderr
&p10Print a value to stdout followed by a newline
&pf10Print a value to stdout
&s10Print a nicely formatted representation of a value to stdout
&sc01Read a line from stdin

Stream

NameGlyphArgsOutputsDescription
&cl10Close a stream by its handle
&rb21Read n bytes from a stream
&rl11Read lines from a stream
&rs21Read characters formed by n bytes from a stream
&ru21Read from a stream until a delimiter is reached
&seek20Move to an absolute position in a file stream
&w20Write an array to a stream

Tcp

NameGlyphArgsOutputsDescription
&fetch11Fetch data from a url
&tcpa11Accept a connection with a TCP or TLS listener
&tcpaddr11Get the connection address of a TCP socket
&tcpc11Create a TCP socket and connect it to an address
&tcpl11Create a TCP listener and bind it to an address
&tcpsnb11Set a TCP socket to non-blocking mode
&tcpsrt20Set the read timeout of a TCP socket in seconds
&tcpswt20Set the write timeout of a TCP socket in seconds
&tlsc11Create a TCP socket with TLS support
&tlsl31Create a TLS listener and bind it to an address

Thread

NameGlyphArgsOutputsDescription
pool1Spawn a thread in a thread pool
recv11Receive a value from a thread
send20Send a value to a thread
spawn1Spawn a thread
tryrecv11Try to receive a value from a thread
wait11Wait for a thread to finish and return its results

Time

NameGlyphArgsOutputsDescription
datetime11Get the date and time information from a time
now01Get the current time in seconds
timezone01Get the local timezone offset

UDP

NameGlyphArgsOutputsDescription
&udpb11Bind a UDP socket
&udpr12Receive a single message from a UDP socket
&udps30Send a message on a UDP socket
&udpsml20Set the maximum message length for incoming messages

Functions

# Named function
Square ← × . # dup then multiply
 
# Call it
Square 5     # → 25

Try it

  • uiua.org pad — online playground
  • cargo install uiua for the CLI