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 ofe1 ... en
.
-
(/ e0 e1 ... en)
Divides
e0
by the product ofe1 ... 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, evaluatesthen
, otherwise, evaluateselse
.
-
(when condition then)
Synonym for
if
whereelse
defaults toNIL
.
-
(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
andbreak
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¶
-
(require module-path)
Loads a module given its
module-path
, importing the exposed symbols to the current environment with respect to the export list created byprovide
.
-
(provide symbols...)
Creates an export list of
symbols
when loaded throughrequire
.
-
(setn name value)
Lexically binds a literal
name
to avalue
.
-
(setr name-ref value)
Lexically binds an evaluated
name-ref
to avalue
.
-
(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 abody
. Binds to a closure when created inside of one.
-
(mkfn name [args...] body)
Creates a scoped function given a
name
, a vector ofargs
, and abody
. Binds to a closure when created inside of one.
-
(macro name [qargs...] body)
Creates a scoped macro given a
name
, a vector ofqargs
, and abody
. Binds to a closure when created inside of one.
-
(let [[name value]...] body)
Creates a closure where each
value
is bound to aname
before evaluatingbody
.
String¶
-
(concat s0 s1 ... sn)
Concatenates strings together.
Vector¶
-
(merge v0 v1 ... vn)
Merges vectors together.
-
(slice vector start stop step)
Slices a
vector
usingstart
,stop
, andstep
.
-
(at index vector)
Returns an item from a
vector
given itsindex
.
-
(remove index vector)
Removes an item from a
vector
given itsindex
.
-
(len vector)
Returns the length of a
vector
.
-
(cons item vector)
Prepends an
item
to avector
.
-
(snoc vector item)
Appends an
item
to avector
.
-
(is-map vector)
Verifies if the
vector
is a map.
-
(map-in vector atom)
Checks whether
atom
is a member ofvector
.
-
(map-at vector atom)
Obtains the value bound to
atom
invector
.
-
(map-up vector atom value)
Sets or updates the
atom
member ofvector
withatom
.