All built-in functions are automatically available without imports.
Function Signature Description +(Fn ['a 'a ...] 'a)Addition (variadic) -(Fn ['a] 'a) or (Fn ['a 'a ...] 'a)Unary negation or subtraction *(Fn ['a 'a ...] 'a)Multiplication (variadic) /(Fn ['a 'a] 'a)Division mod(Fn ['a 'a] 'a)Modulo
Arithmetic operators are polymorphic over numeric types. The operands are unified — all must be the same type.
( - 5 ) ;; => -5 (unary negation)
Function Signature Description =(Fn ['a 'a] Bool)Equality !=(Fn ['a 'a] Bool)Inequality <(Fn ['a 'a] Bool)Less than >(Fn ['a 'a] Bool)Greater than <=(Fn ['a 'a] Bool)Less than or equal >=(Fn ['a 'a] Bool)Greater than or equal
Function Signature Description not(Fn [Bool] Bool)Logical NOT and(Fn [Bool ...] Bool)Logical AND (variadic) or(Fn [Bool ...] Bool)Logical OR (variadic)
( and true true) ;; => true
( or false true) ;; => true
Function Signature Description println(Fn ['a] Unit)Print a value followed by a newline print(Fn ['a] Unit)Print a value without a newline str(Fn ['a ...] String)Concatenate values into a string
(println " Hello " ) ;; prints: Hello\n
( print " no newline " ) ;; prints: no newline
(str " x = " x " , y = " y) ;; => "x = 5, y = 10"
(println) ;; prints a blank line
Function Signature Description len(Fn ['a] i64)Length of a vector, map, or string nth(Fn [(Vector 'a) i64] 'a)Get element at index append(Fn [(Vector 'a) 'a] (Vector 'a))Append element to vector set-nth(Fn [(Vector 'a) i64 'a] (Vector 'a))Return new vector with element at index replaced
( nth [10 20 30] 1 ) ;; => 20
( append [1 2] 3 ) ;; => [1 2 3]
(set-nth [1 2 3] 1 99 ) ;; => [1 99 3]
All take a single f64 and return f64:
Function Description sqrtSquare root floorFloor (round down) ceilCeiling (round up) roundRound to nearest integer sinSine cosCosine tanTangent asinArcsine acosArccosine atanArctangent expe^x logNatural logarithm
Function Signature Description pow(Fn [f64 f64] f64)x raised to the power y atan2(Fn [f64 f64] f64)Two-argument arctangent
(pow 2.0 10.0 ) ;; => 1024.0
(atan2 1.0 1.0 ) ;; => 0.7853981633974483
Function Signature Description abs(Fn ['a] 'a)Absolute value (any numeric type) min(Fn ['a 'a] 'a)Minimum of two values max(Fn ['a 'a] 'a)Maximum of two values
Function Signature Description to-f64(Fn ['a] f64)Convert to f64 to-i64(Fn ['a] i64)Convert to i64 to-f32(Fn ['a] f32)Convert to f32 to-i32(Fn ['a] i32)Convert to i32
(to-f32 3.14 ) ;; => 3.14 (narrowed)
Function Signature Description string-length(Fn [String] i64)Length of string substring(Fn [String i64 i64] String)Extract substring (start, end) string-ref(Fn [String i64] i64)Get character code at index string-contains(Fn [String String] Bool)Check if string contains substring string-upcase(Fn [String] String)Convert to uppercase string-downcase(Fn [String] String)Convert to lowercase string-trim(Fn [String] String)Trim whitespace from both ends char-to-string(Fn [i64] String)Convert character code to string
(string-length " hello " ) ;; => 5
(substring " hello world " 0 5 ) ;; => "hello"
(string-ref " hello " 0 ) ;; => 104 (ASCII 'h')
(string-contains " hello " " ell " ) ;; => true
( string-upcase " hello " ) ;; => "HELLO"
( string-downcase " HELLO " ) ;; => "hello"
( string-trim " hello " ) ;; => "hello"
(char-to-string 65 ) ;; => "A"
Function Signature Description random(Fn [] f64)Random float in [0, 1) random-int(Fn [i64] i64)Random integer in [0, n) random-seed(Fn [i64] Unit)Seed the random number generator
( random ) ;; => 0.7234... (varies)
(random-int 100 ) ;; => 42 (varies, in [0, 100))
(random-seed 12345 ) ;; set seed for reproducibility
Function Signature Description read-file(Fn [String] String)Read entire file contents write-file(Fn [String String] Unit)Write string to file
( let ((contents (read-file " data.txt " )))
(write-file " output.txt " " Hello, file! " )
Function Signature Description sleep(Fn [i64] Unit)Sleep for N milliseconds time-ms(Fn [] i64)Current time in milliseconds
(println (str " Elapsed: " ( - (time-ms) start) " ms " )))
Function Signature Description type-of(Fn ['a] String)Get the type name of a value at runtime
( type-of " hello " ) ;; => "String"
Function Signature Description atom(Fn ['a] (Atom 'a))Create an atomic reference deref(Fn [(Atom 'a)] 'a)Read the current value
( let ((counter ( atom 0 )))
(println (deref counter))) ;; => 0
Function Signature Description channel(Fn [] (Channel 'a))Create a typed channel send(Fn [(Channel 'a) 'a] Unit)Send a value on a channel recv(Fn [(Channel 'a)] 'a)Receive a value from a channel
Function Signature Description par-map(Fn [(Fn ['a] 'b) (Vector 'a)] (Vector 'b))Parallel map over a vector par-for-each(Fn [(Fn ['a] Unit) (Vector 'a)] Unit)Parallel for-each over a vector
Function Signature Description term-init(Fn [] Unit)Initialize terminal raw mode term-restore(Fn [] Unit)Restore terminal to normal mode read-key(Fn [] i64)Read a single keypress (returns key code)