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
Name Glyph Args Outputs Description derivative∂“ 1Calculate the derivative of a mathematical expression fft“ 11Run the Fast Fourier Transform on an array geometric⩜“ 1Convert an operation to be in geometric algebra hsv“ 11Convert a color array from RGB to HSV integral∫“ 1Calculate an antiderivative of a mathematical expression oklch“ 11Convert a color array from RGB to Oklch path“ “ 2Find the shortest path between two things recur“ “ 1Execute a recursive or tree algorithm regex“ 21Match a regex pattern
Arguments
Name Glyph Args Outputs Description above◠“ 1Keep all arguments to a function before the outputs backward˜“ 1Call a function with its arguments swapped below◡“ 1Keep all arguments to a function after the outputs both∩“ 1Call a function on two sets of values bracket⊓“ 1Call two functions on two distinct sets of values by⊸“ 1Call a function but keep its last argument after its outputs dip⊙“ 1Skip 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 fork⊃“ 1Call two functions on the same values gap⋅“ 1Discard the first argument then call a function identity∘11Do nothing with one value off⤚“ 1Call a function but keep its first argument after its outputs old reach𝄐“ 1Old reach on⟜“ 1Call a function but keep its first argument before its outputs pop◌10Discard the first argument reach∪“ 1Call a function skipping the second argument self˙“ 1Call a function with the same array as all arguments with⤙“ 1Call a function but keep its last argument before its outputs
Command
Name Glyph Args Outputs Description &invk“ 10Invoke a path with the system’s default program &runc“ 13Run a command and wait for it to finish &runi“ 11Run a command and wait for it to finish &runs“ 13Run a command with streaming IO
Comptime
Name Glyph Args Outputs Description comptime“ “ 1Run a function at compile time quote“ 01Convert a string into code at compile time
Constant
Name Glyph Args Outputs Description etaη01The number of radians in a quarter circle infinity∞01The 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
Name Glyph Args Outputs Description args?00Debug print all arguments without consuming them dump“ 00Preprocess and print all arguments without popping them
DyadicArray
Name Glyph Args Outputs Description base⊥21Get the base digits of a number couple⊟21Combine two arrays as rows of a new array drop↘21Drop the first n rows of an array find⌕21Find the occurrences of one array in another indexin⨂21Find the first index in an array of each row of another array indexof⊗21Find the first index of each row of one array in another join⊂21Append two arrays end-to-end keep▽21Discard or copy some rows of an array mask⦷21Mask the occurrences of one array in another match≍21Check if two arrays are exactly the same memberof∊21Check if each row of one array exists in another orient⤸21Change the order of the axes of an array pick⊡21Index a row or elements from an array rerank☇21Change the rank of an array’s rows reshape↯21Change the shape of an array rotate↻21Rotate the elements of an array by n select⊏21Select multiple rows from an array take↙21Take the first n rows of an array windows◫21The n-wise windows of an array
DyadicPervasive
Name Glyph Args Outputs Description add+21Add values atangent∠21Take the arctangent of two numbers complexℂ21Make a complex number divide÷21Divide values equals=21Compare for equality greater or equal≥21Compare for greater than or equal greater than>21Compare for greater than less or equal≤21Compare for less than or equal less than<21Compare for less than maximum↥21Take the maximum of two arrays minimum↧21Take the minimum of two arrays modulo◿21Modulo values multiply×21Multiply values not equals≠21Compare for inequality or∨21Logical OR and greatest common divisor powerⁿ21Raise a value to a power subtract-21Subtract values
Encoding
Name Glyph Args Outputs Description apng“ 21Encode an array of image frames in an APNG-encoded byte array audio“ 31Encode audio into a byte array binary“ 11Encode an array into a compact binary representation bytes“ 21Convert a value to a byte representation compress“ 21Compress bytes according to some algorithm csv“ 11Encode an array into a CSV string gif“ 21Encode an array of image frames in a GIF-encoded byte array graphemes“ 11Convert a string to a list of UTF-8 grapheme clusters img“ 21Encode an image into a byte array with the specified format json“ 11Encode an array into a JSON string layout“ 21Render text into an image array parse⋕11Parse a string as a number utf₈“ 11Convert a string to UTF-8 bytes voxels“ 11Project a voxel array to an image xlsx“ 11Encode an array into XLSX bytes
Env
Name Glyph Args Outputs Description &args“ 01Get the command line arguments &raw“ 10Set the terminal to raw mode &ts“ 01Get the size of the terminal &var“ 11Get the value of an environment variable
Environment
Name Glyph Args Outputs Description arch“ 01Get the current architecture dllext“ 01Get the DLL extension for the current platform exeext“ 01Get the executable extension for the current platform numprocs“ 01Get the number of processors on the current system os“ 01Get the current operating system osfamily“ 01Get the current operating system family pathsep“ 01Get the primary path separator for the current platform
Ffi
Name Glyph Args Outputs Description &ffi“ 21Call a foreign function interface &malloc“ 11Allocate memory for the given number of bytes and return a pointer to it &memcpy“ 21Copy data from a pointer into an array &memfree“ 10Free a pointer &memset“ 30Write data from an array into a pointer
Filesystem
Name Glyph Args Outputs Description &cd“ 10Change the current directory &fc“ 11Create a file and return a handle to it &fde“ 10Delete a file or directory &fe“ 11Check if a file, directory, or symlink exists at a path &fif“ 11Check if a path is a file &fld“ 11List the contents of a directory &fmd“ 10Create a directory &fo“ 11Open a file and return a handle to it &frab“ 11Read all the contents of a file into a byte array &fras“ 11Read all the contents of a file into a string &ftr“ 10Move a file or directory to the trash &fwa“ 20Write the entire contents of an array to a file
InversionModifier
Name Glyph Args Outputs Description anti⌝“ 1Invert the behavior of a function, treating its first argument as a constant obverse⌅“ 1Define the various inverses of a function un°“ 1Invert the behavior of a function under⍜“ 1Operate on a transformed array, then reverse the transformation
IteratingModifier
Name Glyph Args Outputs Description do⍢“ 1Repeat a function while a condition holds fold∧“ 1Apply a function to aggregate arrays reduce/“ 1Apply a reducing function to an array repeat⍥“ 1Repeat a function a number of times scan\11Reduce, but keep intermediate values
Map
Name Glyph Args Outputs Description get“ 21Get the value corresponding to a key in a map array has“ 21Check if a map array has a key insert“ 31Insert a key-value pair into a map array map“ 21Create a hashmap from a list of keys and list values remove“ 21Remove the value corresponding to a key from a map array
MappingModifier
Name Glyph Args Outputs Description each∵“ 1Apply a function to each element of an array or arrays group⊕“ 1Group elements of an array into buckets by index inventory⍚“ 1Apply a function to each unboxed row of an array and re-box the results partition⊜“ 1Group sequential sections of an array rows≡“ 1Apply a function to each row of an array or arrays stencil⧈21Call a function on windows of an array table⊞“ 1Apply a function to each combination of rows of some arrays tuples⧅“ 1Get permutations or combinations of an array
Name Glyph Args Outputs Description &ap“ 10Play some audio &apngs“ 20Show an APNG &asr“ 01Get the sample rate of the audio output backend &ast“ 00Synthesize and stream audio &gifs“ 20Show a gif &ims“ 10Show an image
Misc
Name Glyph Args Outputs Description &b“ 00Pause the execution and print the argument list &camcap“ 11Capture an image from a webcam &camlist“ 01List names of available webcams &clip“ 01Get the contents of the clipboard &exit“ 10Exit the program with a status code &sl“ 10Sleep for n seconds assert⍤20Throw an error if a condition is not met case⍩“ 1Call a pattern matching case pattern⍡“ 1Choose different cases based on pattern matching pretty“ 11Convert a value to its pretty-printed output representation repr“ 11Convert a value to its code representation try⍣“ 1Call a function and catch errors type“ 11Check the type of an array
MonadicArray
Name Glyph Args Outputs Description bits⋯11Encode an array as bits (LSB-first) box□11Turn an array into a box classify⊛11Assign a unique index to each unique row in an array deduplicate◴11Remove duplicate rows from an array deshape♭11Make an array 1-dimensional fall⍖11Get the indices into an array if it were sorted descending first⊢11Get the first row of an array fix¤11Add a length-1 axis to an array last⊣11Get the last row of an array length⧻11Get the number of rows in an array occurrences⧆11Mark each row of an array with its occurrence count range⇡11Make an array of all natural numbers less than a number reverse⇌11Reverse the rows of an array rise⍏11Get the indices into an array if it were sorted ascending shape△11Get the dimensions of an array sort⍆11Sort an array transpose⍉11Rotate the shape of an array unique◰11Get a mask of first occurrences of items in an array where⊚11Get indices where array values are not equal to zero
MonadicPervasive
Name Glyph Args Outputs Description absolute value⌵11Get the absolute value of a number ceiling⌈11Round to the nearest integer towards ∞ exponentialₑ11Get the exponential of a number floor⌊11Round to the nearest integer towards ¯∞ negate¯11Negate a number not¬11Logical not reciprocal⨪11Get the reciprocal of a number round⁅11Round to the nearest integer sign±11Numerical sign (1, ¯1, or 0) sine∿11Get the sine of a number sqrt√11Take the square root of a number
OtherModifier
Name Glyph Args Outputs Description content◇“ 1Unbox the arguments to a function before calling it evert⧋“ 1Call a function with its arguments’ axes reversed fill⬚“ 1Set the fill value for a function memo“ “ 1Memoize a function switch⨬“ 1Call the function at the given index
RNG
Name Glyph Args Outputs Description gen“ 21Generate an array of random numbers with a seed noise“ 31Generate random noise random⚂01Generate a random number in the range [0, 1)
StdIO
Name Glyph Args Outputs Description &ep“ 10Print a value to stderr followed by a newline &epf“ 10Print a value to stderr &p“ 10Print a value to stdout followed by a newline &pf“ 10Print a value to stdout &s“ 10Print a nicely formatted representation of a value to stdout &sc“ 01Read a line from stdin
Stream
Name Glyph Args Outputs Description &cl“ 10Close a stream by its handle &rb“ 21Read n bytes from a stream &rl“ 11Read lines from a stream &rs“ 21Read characters formed by n bytes from a stream &ru“ 21Read from a stream until a delimiter is reached &seek“ 20Move to an absolute position in a file stream &w“ 20Write an array to a stream
Tcp
Name Glyph Args Outputs Description &fetch“ 11Fetch data from a url &tcpa“ 11Accept a connection with a TCP or TLS listener &tcpaddr“ 11Get the connection address of a TCP socket &tcpc“ 11Create a TCP socket and connect it to an address &tcpl“ 11Create a TCP listener and bind it to an address &tcpsnb“ 11Set a TCP socket to non-blocking mode &tcpsrt“ 20Set the read timeout of a TCP socket in seconds &tcpswt“ 20Set the write timeout of a TCP socket in seconds &tlsc“ 11Create a TCP socket with TLS support &tlsl“ 31Create a TLS listener and bind it to an address
Thread
Name Glyph Args Outputs Description pool“ “ 1Spawn a thread in a thread pool recv“ 11Receive a value from a thread send“ 20Send a value to a thread spawn“ “ 1Spawn a thread tryrecv“ 11Try to receive a value from a thread wait“ 11Wait for a thread to finish and return its results
Time
Name Glyph Args Outputs Description datetime“ 11Get the date and time information from a time now“ 01Get the current time in seconds timezone“ 01Get the local timezone offset
UDP
Name Glyph Args Outputs Description &udpb“ 11Bind a UDP socket &udpr“ 12Receive a single message from a UDP socket &udps“ 30Send a message on a UDP socket &udpsml“ 20Set 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