Builtins Reference
Every built-in function, organized by category.
Arithmetic
+
Add two or more numbers.
-
Subtract. With one argument, negates.
*
Multiply two or more numbers.
/
Divide. Integer division for ints, float division for floats.
%
Modulo (remainder after division).
Comparison
=
Structural equality. Works on all types.
!=
Structural inequality.
<
Less than. Numbers and strings.
>
Greater than. Numbers and strings.
<=
Less than or equal.
>=
Greater than or equal.
Logic
not
Logical negation. Returns true if the argument is false.
and
Logical AND. Eager; evaluates both arguments.
or
Logical OR. Eager; evaluates both arguments.
String
str
Convert to string, or concatenate multiple values into a string.
len
Return the length of a string or collection.
split
Split a string by a delimiter: [split "," "a,b,c"]
join
Join a collection into a string with a separator: [join ", " items]
trim
Remove leading and trailing whitespace.
replace
Replace occurrences in a string: [replace "old" "new" s]
uppercase
Convert a string to uppercase.
lowercase
Convert a string to lowercase.
starts-with?
Return true if a string starts with the given prefix.
ends-with?
Return true if a string ends with the given suffix.
char-at
Return the character at a given index: [char-at 0 s]
substring
Extract a substring: [substring start end s]
index-of
Return the index of a substring, or -1 if not found.
contains?
Return true if a string contains a substring, or a collection contains an element.
Collections
map
Apply a function to each element: [map f coll]
filter
Keep elements where the predicate returns true: [filter f coll]
fold
Reduce a collection: [fold coll init f] or [fold init f coll]
conj
Add an element to a collection: [conj coll elem]
nth
Get element at index: [nth idx coll]
get
Get a value by key, with optional default: [get m :key default]
assoc
Associate a key with a value in a map: [assoc m :key val]
update
Update a value in a map by applying a function: [update m :key f]
keys
Return the keys of a map as a vector.
values
Return the values of a map as a vector.
entries
Return key-value pairs of a map as a vector of vectors.
merge
Merge two or more maps. Later values win.
remove
Remove elements matching a predicate, or a key from a map.
sort
Sort a collection in natural order.
sort-by
Sort by a key function: [sort-by f coll]
reverse
Reverse a collection.
take
Take the first n elements: [take n coll]
drop
Drop the first n elements: [drop n coll]
each
Execute a side-effecting function for each element. Returns None.
find
Return the first element matching a predicate, or None.
any?
Return true if any element matches the predicate.
all?
Return true if all elements match the predicate.
zip
Combine two collections element-wise into pairs.
flatten
Flatten a nested collection by one level.
chunk
Split a collection into groups of n: [chunk n coll]
flat-map
Map then flatten: [flat-map f coll]
group-by
Group elements by a key function: [group-by f coll]
cons
Prepend an element to a list: [cons elem coll]
collect
Collect a lazy sequence into a vector.
into-map
Convert a collection of key-value pairs into a map.
range
Generate a range of integers: [range end] or [range start end]
push!
Mutably append to a vector. Use sparingly.
empty?
Return true if a collection or string is empty.
sum
Sum all numbers in a collection.
min
Return the smallest value in a collection.
max
Return the largest value in a collection.
Type Checks
map?
Return true if the value is a map.
vec?
Return true if the value is a vector.
Conversion
name
Convert a keyword to its string name: [name :foo] "foo"
int
Convert a value to an integer.
float
Convert a value to a float.
str
Convert any value to its string representation.
IO
println
Print a value followed by a newline.
Print a value without a trailing newline.
Physics
unit : Number -> Keyword -> Dim
Create a dimensional value: [unit 5.0 :m] or use literal syntax 5.0m. Supports 30+ units with SI prefixes.
magnitude : Dim -> Float
Extract the raw float from a dimensional value. This is the explicit exit from the physics type world.
scalar : Float -> Scalar
Wrap a float as a dimensionless Scalar. This is the explicit entry into the physics type world.
Physics Constants
Const.c
Speed of light: 299,792,458 m/s (Velocity)
Const.G
Gravitational constant: 6.674e-11 m³/(kg·s²)
Const.h
Planck constant: 6.626e-34 J·s (Energy × Time)
Const.k-B
Boltzmann constant: 1.381e-23 J/K
Const.e-charge
Elementary charge: 1.602e-19 C (Charge)