API

%

(% dividend divisor)

Return the remainder of dividend / divisor.

*

(* & xs)

Returns the product of all elements in xs. All elements in xs must be numbers. If xs is empty, return 1.

**

(** a x)

Return a to the power of x.

*ns*

+

(+ & xs)

Returns the sum of all elements in xs. All elements xs must be numbers. If xs is empty, return 0.

-

(- & xs)

Returns the difference of all elements in xs. If xs is empty, return 0. If xs has one element, return the negative value of that element.

/

(/ & xs)

Returns the nominator divided by all the denominators. If xs is empty, returns 1. If xs has one value, returns the reciprocal of x.

<

(< a & more)

Checks if each argument is strictly less than the following argument. Returns a boolean.

<=

(<= a & more)

Checks if each argument is less than or equal to the following argument. Returns a boolean.

=

(= a & more)

Checks if all values are equal. Same as a == b in PHP.

>

(> a & more)

Checks if each argument is strictly greater than the following argument. Returns a boolean.

>=

(>= a & more)

Checks if each argument is greater than or equal to the following argument. Returns a boolean.

NAN

Constant for Not a Number (NAN) values.

__DIR__

(__DIR__)

all?

(all? pred xs)

Returns true if (pred x) is logical true for every x in xs, else false.

and

(and & args)

Evaluates each expression one at a time, from left to right. If a form returns logical false, and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expression. Calling the and function without arguments returns true.

array

(array & xs)

Creates a new Array. If no argument is provided, an empty Array is created.

array?

(array? x)

Returns true if x is a array, false otherwise.

bit-and

(bit-and x y & args)

bit-clear

(bit-clear x n)

bit-flip

(bit-flip x n)

bit-not

(bit-not x)

bit-or

(bit-or x y & args)

bit-set

(bit-set x n)

bit-shift-left

(bit-shift-left x n)

bit-shift-right

(bit-shift-right x n)

bit-test

(bit-test x n)

bit-xor

(bit-xor x y & args)

boolean?

(boolean? x)

Returns true if x is a boolean, false otherwise.

case

(case e & pairs)

Takes an expression e and a set of test-content/expression pairs. First evaluates e and the then finds the first pair where the test-constant matches the result of e. The associated expression is then evaluated and returned. If no matches can be found a final last expression can be provided that is than evaluated and return. Otherwise, nil is returned.

comment

(comment &)

Ignores the body of the comment.

comp

(comp & fs)

compare

(compare x y)

An integer less than, equal to, or greater than zero when x is less than, equal to, or greater than y, respectively.

complement

(complement f)

concat

(concat arr & xs)

Concatenates multiple sequential data structures.

cond

(cond & pairs)

Takes a set of test/expression pairs. Evaluates each test one at a time. If a test returns logically true, the expression is evaluated and return. If no test matches a final last expression can be provided that is than evaluated and return. Otherwise, nil is returned.

cons

(cons x xs)

Prepends x to the beginning of xs.

count

(count xs)

Counts the number of elements in a sequence. Can be used on everything that implement the PHP Countable interface.

dec

(dec x)

Decrements x by one.

declare

(declare name)

Declare a global symbol before it is defined.

def-

Define a private value that will not be exported.

defmacro

(defmacro name & fdecl)

Define a macro.

defmacro-

(defmacro- name & fdecl)

Define a private macro that will not be exported.

defn

(defn name & fdecl)

Define a new global function.

defn-

(defn- name & fdecl)

Define a private function that will not be exported.

defstruct

(defstruct name keys)

Define a new struct.

distinct

(distinct xs)

Returns an array with duplicated values removed in xs.

dofor

(dofor head & body)

Repeatedly executes body for side effects with bindings and modifiers as provided by for. Returns nil.

drop

(drop n xs)

drop-while

(drop-while pred xs)

empty?

(empty? x)

Returns true if (count x) is zero, false otherwise.

even?

(even? x)

Checks if x is even.

extreme

(extreme order args)

Returns the most extreme value in args based on the binary order function.

false?

(false? x)

Checks if x is false. Same as x === false in PHP.

ffirst

(ffirst xs)

Same as (first (first xs))

filter

(filter pred xs)

find

(find pred xs)

find-index

(find-index pred xs)

first

(first xs)

Returns the first element of an indexed sequence or nil.

flatten

(flatten xs)

Takes a nested sequential data structure (tree), and returns their contents as a single, flat array.

float?

(float? x)

Returns true if x is float point number, false otherwise.

for

(for head & body)

List comprehension. The head of the loop is a tuple that contains a sequence of bindings and modifiers. A binding is a sequence of three values binding :verb expr. Where binding is a binding as in let and :verb is one of the following keywords:

After each loop binding additional modifiers can be applied. Modifiers have the form :modifier argument. The following modifiers are supported:

The for loops returns a array with all evaluated elements of the body.

frequencies

(frequencies xs)

function?

(function? x)

Returns true if x is a function, false otherwise.

gensym

(gensym )

Generates a new unique symbol.

get

(get ds k & [opt])

Get the value mapped to key from the datastructure ds. Returns opt or nil if the value cannot be found.

get-in

(get-in ds ks & [opt])

group-by

(group-by f xs)

Returns a table of the elements of xs keyed by the result of f on each element.

http/create-response-from-string

(create-response-from-string s)

Create a response from a string.

http/create-response-from-table

(create-response-from-table @{:status status :headers headers :body body :version version :reason reason})

Creates a response struct from a table. The table can have the following keys:

http/emit-response

(emit-response response)

Emits the response.

http/files-from-globals

(files-from-globals & [files])

Extracts the files from $_FILES and normalizes them to a table of "uploaded-file".

http/headers-from-server

(headers-from-server & [server])

Extracts all headers from the $_SERVER variable.

http/request

(request method uri headers parsed-body query-params cookie-params server-params uploaded-files version)

Creates a new request struct.

http/request-from-globals

(request-from-globals & [server])

Extracts a request from $_SERVER.

http/request?

(request? x)

Checks if x is a instance of the request struct.

http/response

(response status headers body version reason)

Creates a new response struct.

http/response?

(response? x)

Checks if x is an instance of the response struct

http/uploaded-file

(uploaded-file tmp-file size error-status client-filename client-media-type)

Creates a new uploaded-file struct.

http/uploaded-file?

(uploaded-file? x)

Checks if x is a instance of the uploaded-file struct.

http/uri

(uri scheme userinfo host port path query fragment)

Creates a new uri struct.

http/uri-from-globals

(uri-from-globals & [server])

Extracts the URI from the $_SERVER variable.

http/uri?

(uri? x)

Checks if x is a instance of the uri struct.

id

(id a & more)

Checks if all values are identically. Same as a === b in PHP.

identity

(identity x)

if-not

(if-not test then & [else])

Shorthand for (if (not condition) else then).

inc

(inc x)

Increments x by one.

indexed?

(indexed? x)

Returns true if x is indexed sequence, false otherwise.

int?

(int? x)

Returns true if x is a integer number, false otherwise.

interleave

(interleave & xs)

Returns a array with the first items of each col, than the second items etc.

interpose

(interpose sep xs)

invert

(invert table)

Returns a new table where the keys and values are swapped. If table has duplicated values, some keys will be ignored.

juxt

(juxt & fs)

keep

(keep pred xs)

keep-indexed

(keep-indexed pred xs)

keys

(keys xs)

Gets the keys of an associative data structure.

keyword

(keyword x)

Creates a new Keyword from a given string.

keyword?

(keyword? x)

Returns true if x is a keyword, false otherwise.

kvs

(kvs xs)

Returns an array of key value pairs like @[k1 v1 k2 v2 k3 v3 ...].

map

(map f & xs)

map-indexed

(map-indexed f xs)

Applies f to each element in xs. f is a two argument function. The first argument is index of the element in the sequence and the second element is the element itself.

mapcat

(mapcat f & xs)

Applies f on all xs and concatenate the result.

max

(max & numbers)

Returns the numeric maximum of all numbers.

mean

(mean xs)

Returns the mean of xs.

merge

(merge & tables)

Merges multiple tables into one new table. If a key appears in more than one collection, then later values replace any previous ones.

merge-into

(merge-into tab & tables)

Merges multiple tables into first table. If a key appears in more than one collection, then later values replace any previous ones.

min

(min & numbers)

Returns the numeric minimum of all numbers.

nan?

(nan? x)

Checks if x is not a number.

neg?

(neg? x)

Checks if x is smaller than zero.

next

(next xs)

Returns the sequence of elements after the first element. If there are no elements, returns nil.

nfirst

(nfirst xs)

Same as (next (first xs)).

nil?

(nil? x)

Returns true if x is nil, false otherwise.

nnext

(nnext xs)

Same as (next (next xs))

not

(not x)

The not function returns true if the given value is logical false and false otherwise.

not=

(not= a & more)

Checks if all values are unequal. Same as a != b in PHP.

number?

(number? x)

Returns true if x is a number, false otherwise.

odd?

(odd? x)

Checks if x is odd.

one?

(one? x)

Checks if x is one.

or

(or & args)

Evaluates each expression one at a time, from left to right. If a form returns a logical true value, or returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expression. Calling or without arguments, returns nil.

pairs

(pairs xs)

Gets the pairs of an associative data structure.

partial

(partial f & args)

partition

(partition n xs)

peek

(peek xs)

Returns the last element of a sequence.

php-array-to-table

(php-array-to-table arr)

Converts a PHP Array to a tables.

php-array?

(php-array? x)

Returns true if x is a PHP Array, false otherwise.

php-associative-array

(php-associative-array & xs)

Creates a PHP associative array. An even number of parameters must be provided.

php-indexed-array

(php-indexed-array & xs)

Creates an PHP indexed array from the given values.

php-object?

(php-object? x)

Returns true if x is a PHP object, false otherwise.

php-resource?

(php-resource? x)

Returns true if x is a PHP resource, false otherwise.

pop

(pop xs)

Removes the last element of the array xs. If the array is empty returns nil.

pos?

(pos? x)

Checks if x is greater than zero.

print

(print & xs)

Prints the given values to the default output stream. Returns nil.

(print-str & xs)

Same as print. But instead of writing it to a output stream, The resulting string is returned.

println

(println & xs)

Same as print followed by a newline.

push

(push xs x)

Inserts x at the end of the sequence xs.

put

(put ds key value)

Puts value mapped to key on the datastructure ds. Returns ds.

put-in

(put-in ds [k & ks] v)

rand

(rand )

Returns a random number between 0 and 1.

rand-int

(rand-int n)

Returns a random number between 0 and n.

range

(range a & rest)

Create an array of values [start, end). If the function has one argument the the range [0, end) is returned. With two arguments, returns [start, end). The third argument is an optional step width (default 1).

reduce

(reduce f init xs)

reduce2

(reduce2 f [x & xs])

remove

(remove xs offset & [n])

Removes up to n element from array xs starting at index offset.

repeat

(repeat n x)

Returns an array of length n where every element is x.

rest

(rest xs)

Returns the sequence of elements after the first element. If there are no elements, returns an empty sequence.

reverse

(reverse xs)

Reverses the order of the elements in the given sequence.

second

(second xs)

Returns the second element of an indexed sequence or nil.

shuffle

(shuffle xs)

Returns a random permutation of xs.

slice

(slice xs & [offset & [length]])

Extract a slice of xs.

some?

(some? pred xs)

Returns true if (pred x) is logical true for at least one x in xs, else false.

sort

(sort xs & [comp])

Returns a sorted array. If no comparator is supplied compare is used.

sort-by

(sort-by keyfn xs & [comp])

Returns a sorted array where the sort order is determined by comparing (keyfn item). If no comparator is supplied compare is used.

split-at

(split-at n xs)

Returns a tuple of [(take n coll) (drop n coll)].

split-with

(split-with f xs)

Returns a tuple of [(take-while pred coll) (drop-while pred coll)].

str

(str & args)

Creates a string by concatenating values together. If no arguments are provided an empty string is returned. Nil and false are represented as empty string. True is represented as 1. Otherwise, it tries to call __toString. This is PHP equivalent to $args[0] . $args[1] . $args[2] ....

string?

(string? x)

Returns true if x is a string, false otherwise.

struct?

(struct? x)

Returns true if x is a struct, false otherwise.

sum

(sum xs)

Returns the sum of all elements is xs.

symbol?

(symbol? x)

Returns true if x is a symbol, false otherwise.

table

(table & xs)

Creates a new Table. If no argument is provided, an empty Table is created. The number of parameters must be even.

table?

(table? x)

Returns true if x is a table, false otherwise.

take

(take n xs)

take-while

(take-while pred xs)

to-php-array

(to-php-array xs)

Create a PHP Array from a sequential data structure.

tree-seq

(tree-seq branch? children root)

Returns an array of the nodes in the tree, via a depth first walk. branch? is a function with one argument that returns true if the given node has children. children must be a function with one argument that returns the children of the node. root the root node of the tree.

true?

(true? x)

Checks if x is true. Same as x === true in PHP.

truthy?

(truthy? x)

Checks if x is truthy. Same as x == true in PHP.

tuple

(tuple & xs)

Creates a new Tuple. If no argument is provided, an empty Tuple is created.

tuple-brackets

Creates a new Bracket-Tuple. If no argument is provided, an empty Braket-Tuple is created.

tuple-brackets?

(tuple-brackets? x)

tuple-parens?

(tuple-parens? x)

tuple?

(tuple? x)

Returns true if x is a tuple, false otherwise.

type

(type x)

Returns the type of x. Following types can be returned:

unset

(unset ds key)

Returns ds without key.

update

(update ds k f & args)

update-in

(update-in ds [k & ks] f & args)

values

(values xs)

Gets the values of an associative data structure.

when

(when test & body)

Evaluates test and if that is logical true, evaluates body.

when-not

(when-not test & body)

Evaluates test and if that is logical true, evaluates body.

with-output-buffer

(with-output-buffer & body)

zero?

(zero? x)

Checks if x is zero.

zipcoll

(zipcoll a b)

Creates a table from two sequential data structures. Return a new table.