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¶
- (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.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 ofargs
, and abody
. Binds to a closure when created inside of one. Allows&rest
syntax as described infn
.
- (macro name [args...] body)
Creates a scoped macro given a
name
, a vector ofargs
, and abody
. Binds to a closure when created inside of one. Allows&rest
syntax as described infn
.
- (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
.