Functions

Documentation for the various built-in functions.

Arithmetic

(+ e0 e1 ... en)

Performs a summation of the provided expressions.

(* e0 e1 ... en)

Performs a multiplication of the provided expressions.

(- e0 e1 ... en)

Subtracts e0 by the sum of e1 ... en.

(/ e0 e1 ... en)

Divides e0 by the product of e1 ... en

Boolean

(bool e)

Checks for the truthiness of an expression

(not e)

Checks for the falsiness of an expression

(and e0 e1 ... en)

Evaluates and reduces the expressions using an and operation, short-circuiting evaluation when a falsy value is encountered.

(or e0 e1 ... en)

Evaluates and reduces the expressions using an or operation, short-circuiting evaluation when a truthy value is encountered.

Control

(if condition then else)

Basic branching construct. If condition evaluates to a truthy value, evaluates then, otherwise, evaluates else.

(when condition then)

Synonym for if where else defaults to NIL.

(cond [[condition value] ...])

Traverses pairs of conditions and values. If the condition evaluates to a truthy value, returns the provided value, short-circuiting evaluation. Returns NIL when no conditions are met.

(do expression...)

Evaluates each expression, returning what was evaluated last.

(loop expression...)

Evaluates each expression, looping back at the end. Can be broken by the return and break functions.

(return expression)

Breaks out of a loop evaluating to a value.

(break)

Breaks out of a loop evaluating to NIL.

Comparison

(> x y)

Performs a greater than operation.

(< x y)

Performs a less than operation.

(= x y)

Performs a equal to operation.

(/= x y)

Performs a not equal to operation.

(>= x y)

Performs a greater than or equal to operation.

(<= x y)

Performs a less than or equal to operation.

IO

(print expression)

Prints an expression.

(putstrln string)

Prints the contents of a string.

(exit code)

Stops the execution of the program.

Meta

(setn name value)

Lexically binds a literal name to a value.

(setr name-ref value)

Lexically binds an evaluated name-ref to a value.

(unquote qexpression)

Unquotes a given qexpression.

(eval expression)

Fully evaluates an expression, optionally removing a layer of quoting.

(fn [args...] body)

Creates a scoped lambda given a vector of args, and a body. Binds to a closure when created inside of one.

args can include &rest to signify variadic arguments, and can be used in the following forms.

;; Variadic for all arguments
(= ((fn [&rest] [&rest]) 1 2 3) [[1 2 3]])

;; Non-variadic for first :data:`n` arguments
(= ((fn [x &rest] [x &rest]) 1 2 3) [1 [2 3]])

;; Non-variadic for last :data:`n` arguments
(= ((fn [&rest x] [&rest x]) 1 2 3) [[1 2] 3])

;; Non-variadic for first :data:`n` and last:data:`m` arguments
(= ((fn [x &rest y] [x &rest y]) 1 2 3)) [1 [2] 3])
(mkfn name [args...] body)

Creates a scoped function given a name, a vector of args, and a body. Binds to a closure when created inside of one. Allows &rest syntax as described in fn.

(macro name [args...] body)

Creates a scoped macro given a name, a vector of args, and a body. Binds to a closure when created inside of one. Allows &rest syntax as described in fn.

(let [[name value]...] body)

Creates a closure where each value is bound to a name before evaluating body.

String

(concat s0 s1 ... sn)

Concatenates strings together.

Vector

(merge v0 v1 ... vn)

Merges vectors together.

(slice vector start stop step)

Slices a vector using start, stop, and step.

(at index vector)

Returns an item from a vector given its index.

(remove index vector)

Removes an item from a vector given its index.

(len vector)

Returns the length of a vector.

(cons item vector)

Prepends an item to a vector.

(snoc vector item)

Appends an item to a vector.

(is-map vector)

Verifies if the vector is a map.

(map-in vector atom)

Checks whether atom is a member of vector.

(map-at vector atom)

Obtains the value bound to atom in vector.

(map-up vector atom value)

Sets or updates the atom member of vector with atom.