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
e0by the sum ofe1 ... en.
- (/ e0 e1 ... en)
Divides
e0by 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
conditionevaluates to a truthy value, evaluatesthen, otherwise, evaluateselse.
- (when condition then)
Synonym for
ifwhereelsedefaults 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
NILwhen 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
returnandbreakfunctions.
- (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
nameto avalue.
- (setr name-ref value)
Lexically binds an evaluated
name-refto 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.argscan include&restto 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&restsyntax 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&restsyntax as described infn.
- (let [[name value]...] body)
Creates a closure where each
valueis bound to anamebefore evaluatingbody.
String¶
- (concat s0 s1 ... sn)
Concatenates strings together.
Vector¶
- (merge v0 v1 ... vn)
Merges vectors together.
- (slice vector start stop step)
Slices a
vectorusingstart,stop, andstep.
- (at index vector)
Returns an item from a
vectorgiven itsindex.
- (remove index vector)
Removes an item from a
vectorgiven itsindex.
- (len vector)
Returns the length of a
vector.
- (cons item vector)
Prepends an
itemto avector.
- (snoc vector item)
Appends an
itemto avector.
- (is-map vector)
Verifies if the
vectoris a map.
- (map-in vector atom)
Checks whether
atomis a member ofvector.
- (map-at vector atom)
Obtains the value bound to
atominvector.
- (map-up vector atom value)
Sets or updates the
atommember ofvectorwithatom.