Quick Ref for Clojure Core
Adapted from Johannes Friestad's excellent quick ref.
-
|
+
|
Returns the sum of nums. (+) returns 0. |
1 ex. |
-
|
-
|
If no ys are supplied, returns the negation of x, else subtracts
th |
1 ex. |
-
|
*
|
Returns the product of nums. (*) returns 1. |
1 ex. |
-
|
/
|
If no denominators are supplied, returns 1/numerator,
else returns |
1 ex. |
-
|
quot
|
quot[ient] of dividing numerator by denominator. |
2 ex. |
-
|
rem
|
remainder of dividing numerator by denominator. |
2 ex. |
-
|
mod
|
Modulus of num and div. Truncates toward negative infinity. |
1 ex. |
-
|
inc
|
Returns a number one greater than num. |
1 ex. |
-
|
dec
|
Returns a number one less than num. |
1 ex. |
-
|
max
|
Returns the greatest of the nums. |
1 ex. |
-
|
min
|
Returns the least of the nums. |
1 ex. |
-
|
with-precision
|
Sets the precision and rounding mode to be used for BigDecimal operat |
1 ex. |
-
|
=
|
Equality. Returns true if x equals y, false if not. Same as
Java x. |
1 ex. |
-
|
==
|
Returns non-nil if nums all have the same value, otherwise false |
1 ex. |
-
|
not=
|
Same as (not (= obj1 obj2)) |
1 ex. |
-
|
<
|
Returns non-nil if nums are in monotonically increasing order,
othe |
1 ex. |
-
|
>
|
Returns non-nil if nums are in monotonically decreasing order,
othe |
1 ex. |
-
|
<=
|
Returns non-nil if nums are in monotonically non-decreasing order,
|
1 ex. |
-
|
>=
|
Returns non-nil if nums are in monotonically non-increasing order,
|
1 ex. |
-
|
byte
|
Coerce to byte |
1 ex. |
-
|
short
|
Coerce to short |
1 ex. |
-
-
|
long
|
Coerce to long |
2 ex. |
-
|
float
|
Coerce to float |
1 ex. |
-
-
|
bigint
|
Coerce to BigInteger |
1 ex. |
-
|
bigdec
|
Coerce to BigDecimal |
1 ex. |
-
|
num
|
Coerce to Number |
1 ex. |
-
-
|
nil?
|
Returns true if x is nil, false otherwise. |
1 ex. |
-
|
identical?
|
Tests if 2 arguments are the same object |
1 ex. |
-
|
zero?
|
Returns true if num is zero, else false |
1 ex. |
-
|
pos?
|
Returns true if num is greater than zero, else false |
1 ex. |
-
|
neg?
|
Returns true if num is less than zero, else false |
1 ex. |
-
|
even?
|
Returns true if n is even, throws an exception if n is not an integer |
1 ex. |
-
|
odd?
|
Returns true if n is odd, throws an exception if n is not an integer |
1 ex. |
-
|
keyword
|
Returns a Keyword with the given namespace and name. Do not use :
|
1 ex. |
-
|
symbol
|
Returns a Symbol with the given namespace and name. |
1 ex. |
-
|
name
|
Returns the name String of a string, symbol or keyword. |
1 ex. |
-
|
intern
|
Finds or creates a var named by the symbol name in the namespace
ns |
1 ex. |
-
|
namespace
|
Returns the namespace String of a symbol or keyword, or nil if not pr |
1 ex. |
-
|
keyword?
|
Return true if x is a Keyword |
1 ex. |
-
|
symbol?
|
Return true if x is a Symbol |
1 ex. |
-
|
str
|
With no args, returns the empty string. With one arg x, returns
x.t |
2 ex. |
-
|
print-str
|
print to a string, returning it |
1 ex. |
-
-
|
pr-str
|
pr to a string, returning it |
1 ex. |
-
|
prn-str
|
prn to a string, returning it |
1 ex. |
-
|
with-out-str
|
Evaluates exprs in a context in which *out* is bound to a fresh
Str |
1 ex. |
-
|
count
|
Returns the number of items in the collection. (count nil) returns
|
1 ex. |
-
|
get
|
Returns the value mapped to key, not-found or nil if key not present. |
1 ex. |
-
|
subs
|
Returns the substring of s beginning at start inclusive, and ending
|
1 ex. |
-
|
format
|
Formats a string using java.lang.String.format, see java.util.Formatt |
1 ex. |
-
|
char
|
Coerce to char |
1 ex. |
-
|
char?
|
Return true if x is a Character |
1 ex. |
-
|
string?
|
Return true if x is a String |
1 ex. |
-
|
re-pattern
|
Returns an instance of java.util.regex.Pattern, for use, e.g. in
re |
1 ex. |
-
|
re-matcher
|
Returns an instance of java.util.regex.Matcher, for use, e.g. in
re |
1 ex. |
-
|
re-find
|
Returns the next regex match, if any, of string to pattern, using
j |
2 ex. |
-
|
re-matches
|
Returns the match, if any, of string to pattern, using
java.util.re |
1 ex. |
-
|
re-seq
|
Returns a lazy sequence of successive matches of pattern in string,
|
2 ex. |
-
|
re-groups
|
Returns the groups from the most recent match/find. If there are no
|
1 ex. |
-
|
if
|
Please see http://clojure.org/special_forms#if |
1 ex. |
-
|
if-not
|
Evaluates test. If logical false, evaluates and returns then expr,
|
2 ex. |
-
|
if-let
|
bindings => binding-form test
If test is true, evaluates then with |
3 ex. |
-
|
when
|
Evaluates test. If logical true, evaluates body in an implicit do. |
2 ex. |
-
|
when-not
|
Evaluates test. If logical false, evaluates body in an implicit do. |
1 ex. |
-
|
when-let
|
bindings => binding-form test
When test is true, evaluates body wi |
1 ex. |
-
|
when-first
|
bindings => x xs
Same as (when (seq xs) (let [x (first xs)] body)) |
1 ex. |
-
|
cond
|
Takes a set of test/expr pairs. It evaluates each test one at a
tim |
2 ex. |
-
|
condp
|
Takes a binary predicate, an expression, and a set of clauses.
Each |
4 ex. |
-
|
case
|
Takes an expression, and a set of clauses.
Each clause can take th |
1 ex. |
-
|
do
|
Please see http://clojure.org/special_forms#do |
1 ex. |
-
|
eval
|
Evaluates the form data structure (not text!) and returns the result. |
2 ex. |
-
|
loop
|
Evaluates the exprs in a lexical context in which the symbols in
th |
2 ex. |
-
|
recur
|
Please see http://clojure.org/special_forms#recur |
2 ex. |
-
|
trampoline
|
trampoline can be used to convert algorithms requiring mutual
recur |
1 ex. |
-
|
while
|
Repeatedly executes body while test expression is true. Presumes
so |
1 ex. |
-
|
try
|
Please see http://clojure.org/special_forms#try |
1 ex. |
-
|
catch
|
Please see http://clojure.org/special_forms#try |
1 ex. |
-
|
finally
|
Please see http://clojure.org/special_forms#finally |
1 ex. |
-
|
throw
|
Please see http://clojure.org/special_forms#throw |
1 ex. |
-
|
assert
|
Evaluates expr and throws an exception if it does not evaluate to
lo |
1 ex. |
-
|
delay
|
Takes a body of expressions and yields a Delay object that will
inv |
1 ex. |
-
|
delay?
|
returns true if x is a Delay created with delay |
1 ex. |
-
|
deref
|
Also reader macro: @ref/@agent/@var/@atom/@delay/@future. Within a tr |
1 ex. |
-
|
force
|
If x is a Delay, returns the (possibly cached) value of its expressio |
2 ex. |
-
|
repeatedly
|
Takes a function of no args, presumably with side effects, and
retu |
2 ex. |
-
|
iterate
|
Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of |
3 ex. |
-
|
dotimes
|
bindings => name n
Repeatedly executes body (presumably for side-e |
1 ex. |
-
|
doseq
|
Repeatedly executes body (presumably for side-effects) with
binding |
5 ex. |
-
|
for
|
List comprehension. Takes a vector of one or more
binding-form/col |
6 ex. |
-
|
lazy-seq
|
Takes a body of expressions that returns an ISeq or nil, and yields
|
1 ex. |
-
|
lazy-cat
|
Expands to code which yields a lazy sequence of the concatenation
o |
1 ex. |
-
|
doall
|
When lazy sequences are produced via functions that have side
effec |
1 ex. |
-
|
dorun
|
When lazy sequences are produced via functions that have side
effec |
1 ex. |
-
|
type
|
Returns the :type metadata of x, or its Class if none |
2 ex. |
-
|
extends?
|
Returns true if atype extends protocol |
0 ex. |
-
|
satisfies?
|
Returns true if x satisfies the protocol |
1 ex. |
-
|
class
|
Returns the Class of x |
1 ex. |
-
|
bases
|
Returns the immediate superclass and direct interfaces of c, if any |
1 ex. |
-
|
supers
|
Returns the immediate and indirect superclasses and interfaces of c, |
1 ex. |
-
|
class?
|
Returns true if x is an instance of Class |
1 ex. |
-
|
instance?
|
Evaluates x and tests if it is an instance of the class
c. Return |
2 ex. |
-
|
isa?
|
Returns true if (= child parent), or child is directly or indirectly |
2 ex. |
-
|
cast
|
Throws a ClassCastException if x is not a c, else returns x. |
1 ex. |
-
|
deref
|
Also reader macro: @ref/@agent/@var/@atom/@delay/@future. Within a tr |
1 ex. |
-
|
get-validator
|
Gets the validator-fn for a var/ref/agent/atom. |
0 ex. |
-
|
set-validator!
|
Sets the validator-fn for a var/ref/agent/atom. validator-fn must be |
0 ex. |
-
|
atom
|
Creates and returns an Atom with an initial value of x and zero or
|
1 ex. |
-
|
swap!
|
Atomically swaps the value of atom to be:
(apply f current-value-of |
2 ex. |
-
|
reset!
|
Sets the value of atom to newval without regard for the
current val |
1 ex. |
-
|
compare-and-set!
|
Atomically sets the value of atom to newval if and only if the
curr |
1 ex. |
-
|
ref
|
Creates and returns a Ref with an initial value of x and zero or
mo |
1 ex. |
-
|
sync
|
transaction-flags => TBD, pass nil for now
Runs the exprs (in an i |
0 ex. |
-
|
dosync
|
Runs the exprs (in an implicit do) in a transaction that encompasses
|
1 ex. |
-
|
ref-set
|
Must be called in a transaction. Sets the value of ref.
Returns val |
1 ex. |
-
|
alter
|
Must be called in a transaction. Sets the in-transaction-value of
r |
1 ex. |
-
|
commute
|
Must be called in a transaction. Sets the in-transaction-value of
r |
0 ex. |
-
|
ensure
|
Must be called in a transaction. Protects the ref from modification
|
0 ex. |
-
|
io!
|
If an io! block occurs in a transaction, throws an
IllegalStateExce |
0 ex. |
-
-
|
ref-max-history
|
Gets the max-history of a ref, or sets it and returns the ref |
0 ex. |
-
|
ref-min-history
|
Gets the min-history of a ref, or sets it and returns the ref |
0 ex. |
-
|
agent
|
Creates and returns an agent with an initial value of state and
zer |
1 ex. |
-
|
send
|
Dispatch an action to an agent. Returns the agent immediately.
Subs |
1 ex. |
-
|
send-off
|
Dispatch a potentially blocking action to an agent. Returns the
age |
1 ex. |
-
|
await
|
Blocks the current thread (indefinitely!) until all actions
dispatc |
1 ex. |
-
|
await-for
|
Blocks the current thread until all actions dispatched thus
far (fr |
0 ex. |
-
|
agent-error
|
Returns the exception thrown during an asynchronous action of the
a |
0 ex. |
-
|
restart-agent
|
When an agent is failed, changes the agent state to new-state and
t |
0 ex. |
-
|
shutdown-agents
|
Initiates a shutdown of the thread pools that back the agent
system |
0 ex. |
-
|
*agent*
|
The agent currently running an action on this thread, else nil |
1 ex. |
-
|
error-handler
|
Returns the error-handler of agent a, or nil if there is none.
See |
0 ex. |
-
|
set-error-handler!
|
Sets the error-handler of agent a to handler-fn. If an action
bein |
0 ex. |
-
|
error-mode
|
Returns the error-mode of agent a. See set-error-mode! |
0 ex. |
-
|
set-error-mode!
|
Sets the error-mode of agent a to mode-keyword, which must be
eithe |
0 ex. |
-
-
|
future
|
Takes a body of expressions and yields a future object that will
in |
2 ex. |
-
|
future-call
|
Takes a function of no args and yields a future object that will
in |
0 ex. |
-
-
-
-
|
future?
|
Returns true if x is a future |
0 ex. |
-
|
bound-fn
|
Returns a function defined by the given fntail, which will install th |
0 ex. |
-
|
bound-fn*
|
Returns a function, which will install the same bindings in effect as |
0 ex. |
-
|
get-thread-bindings
|
Get a map with the Var/value pairs which is currently in effect for t |
0 ex. |
-
-
|
pop-thread-bindings
|
Pop one set of bindings pushed with push-binding before. It is an err |
0 ex. |
-
|
thread-bound?
|
Returns true if all of the vars provided as arguments have thread-loc |
0 ex. |
-
|
locking
|
Executes exprs in an implicit do, while holding the monitor of x.
W |
1 ex. |
-
|
pcalls
|
Executes the no-arg fns in parallel, returning a lazy sequence of
t |
1 ex. |
-
|
pvalues
|
Returns a lazy sequence of the values of the exprs, which are
evalu |
1 ex. |
-
|
pmap
|
Like map, except f is applied in parallel. Semi-lazy in that the
pa |
2 ex. |
-
|
seque
|
Creates a queued seq on another (presumably lazy) seq s. The queued
|
1 ex. |
-
|
promise
|
Alpha - subject to change.
Returns a promise object that can be rea |
1 ex. |
-
|
deliver
|
Alpha - subject to change.
Delivers the supplied value to the promi |
1 ex. |
-
|
add-watch
|
Alpha - subject to change.
Adds a watch function to an agent/atom/v |
1 ex. |
-
|
remove-watch
|
Alpha - subject to change.
Removes a watch (set by add-watch) from |
0 ex. |
-
|
fn
|
(fn name? [params* ] exprs*)
(fn name? ([params* ] exprs*)+)
par |
2 ex. |
-
|
defn
|
Same as (def name (fn [params* ] exprs*)) or (def
name (fn ([para |
3 ex. |
-
|
defn-
|
same as defn, yielding non-public def |
1 ex. |
-
|
definline
|
Experimental - like defmacro, except defines a named function whose
|
0 ex. |
-
-
|
constantly
|
Returns a function that takes any number of arguments and returns x. |
2 ex. |
-
|
memfn
|
Expands into code that creates a fn that expects to be passed an
ob |
1 ex. |
-
|
comp
|
Takes a set of functions and returns a fn that is the composition
o |
6 ex. |
-
|
complement
|
Takes a fn f and returns a fn that takes the same arguments as f,
h |
1 ex. |
-
|
partial
|
Takes a function f and fewer than the normal arguments to f, and
re |
2 ex. |
-
|
juxt
|
Alpha - name subject to change.
Takes a set of functions and return |
3 ex. |
-
|
memoize
|
Returns a memoized version of a referentially transparent function. T |
1 ex. |
-
|
->
|
Threads the expr through the forms. Inserts x as the
second item in |
2 ex. |
-
|
->>
|
Threads the expr through the forms. Inserts x as the
last item in t |
1 ex. |
-
|
apply
|
Applies fn f to the argument list formed by prepending args to argseq |
6 ex. |
-
|
fn?
|
Returns true if x implements Fn, i.e. is an object created via fn. |
2 ex. |
-
|
ifn?
|
Returns true if x implements IFn. Note that many data structures
(e |
1 ex. |
-
|
defmulti
|
Creates a new multimethod with the associated dispatch function.
Th |
3 ex. |
-
|
defmethod
|
Creates and installs a new method of multimethod associated with disp |
3 ex. |
-
|
get-method
|
Given a multimethod and a dispatch value, returns the dispatch fn
t |
1 ex. |
-
|
methods
|
Given a multimethod, returns a map of dispatch values -> dispatch fns |
1 ex. |
-
|
prefer-method
|
Causes the multimethod to prefer matches of dispatch-val-x over dispa |
0 ex. |
-
|
prefers
|
Given a multimethod, returns a map of preferred value -> set of other |
0 ex. |
-
|
remove-method
|
Removes the method of multimethod associated with dispatch-value. |
1 ex. |
-
-
|
defmacro
|
Like defn, but the resulting function name is declared as a
macro a |
1 ex. |
-
|
macroexpand
|
Repeatedly calls macroexpand-1 on form until it no longer
represent |
1 ex. |
-
|
macroexpand-1
|
If form represents a macro form, returns its expansion,
else return |
1 ex. |
-
|
gensym
|
Returns a new symbol with a unique name. If a prefix string is
supp |
2 ex. |
-
|
doto
|
Evaluates x then calls all of the methods and functions with the
va |
2 ex. |
-
|
..
|
form => fieldName-symbol or (instanceMethodName-symbol args*)
Expa |
1 ex. |
-
|
set!
|
Please see http://clojure.org/special_forms#set |
1 ex. |
-
|
make-array
|
Creates and returns an array of instances of the specified class of
|
2 ex. |
-
-
-
-
-
-
-
-
-
-
|
aclone
|
Returns a clone of the Java array. Works on arrays of known
types. |
1 ex. |
-
|
to-array
|
Returns an array of Objects containing the contents of coll, which
|
1 ex. |
-
|
to-array-2d
|
Returns a (potentially-ragged) 2-dimensional array of Objects
conta |
2 ex. |
-
|
into-array
|
Returns an array with components set to the values in aseq. The array |
1 ex. |
-
|
aget
|
Returns the value at the index/indices. Works on Java arrays of all
|
1 ex. |
-
|
aset
|
Sets the value at the index/indices. Works on Java arrays of
refere |
1 ex. |
-
|
aset-boolean
|
Sets the value at the index/indices. Works on arrays of boolean. Retu |
1 ex. |
-
|
aset-char
|
Sets the value at the index/indices. Works on arrays of char. Returns |
1 ex. |
-
|
aset-byte
|
Sets the value at the index/indices. Works on arrays of byte. Returns |
1 ex. |
-
|
aset-int
|
Sets the value at the index/indices. Works on arrays of int. Returns |
1 ex. |
-
|
aset-long
|
Sets the value at the index/indices. Works on arrays of long. Returns |
1 ex. |
-
|
aset-short
|
Sets the value at the index/indices. Works on arrays of short. Return |
1 ex. |
-
|
aset-float
|
Sets the value at the index/indices. Works on arrays of float. Return |
1 ex. |
-
|
aset-double
|
Sets the value at the index/indices. Works on arrays of double. Retur |
1 ex. |
-
|
alength
|
Returns the length of the Java array. Works on arrays of all
types. |
1 ex. |
-
|
amap
|
Maps an expression across an array a, using an index named idx, and
|
1 ex. |
-
|
areduce
|
Reduces an expression across an array a, using an index named idx,
|
1 ex. |
-
-
|
bytes
|
Casts to bytes[] |
0 ex. |
-
|
chars
|
Casts to chars[] |
0 ex. |
-
|
ints
|
Casts to int[] |
0 ex. |
-
|
shorts
|
Casts to shorts[] |
0 ex. |
-
|
longs
|
Casts to long[] |
0 ex. |
-
-
-
|
proxy
|
class-and-interfaces - a vector of class names
args - a (possibly |
1 ex. |
-
|
get-proxy-class
|
Takes an optional single class followed by zero or more
interfaces. |
0 ex. |
-
|
construct-proxy
|
Takes a proxy class and any arguments for its superclass ctor and
c |
0 ex. |
-
|
init-proxy
|
Takes a proxy instance and a map of strings (which must
correspond |
0 ex. |
-
|
proxy-mappings
|
Takes a proxy instance and returns the proxy's fn map. |
0 ex. |
-
|
proxy-super
|
Use to call a superclass method in the body of a proxy method.
Not |
0 ex. |
-
|
update-proxy
|
Takes a proxy instance and a map of strings (which must
correspond |
1 ex. |
-
|
count
|
Returns the number of items in the collection. (count nil) returns
|
1 ex. |
-
|
empty
|
Returns an empty collection of the same category as coll, or nil |
1 ex. |
-
|
not-empty
|
If coll is empty, returns nil, else coll |
1 ex. |
-
|
into
|
Returns a new coll consisting of to-coll with all of the items of
f |
2 ex. |
-
|
conj
|
conj[oin]. Returns a new collection with the xs
'added'. (conj ni |
1 ex. |
-
|
contains?
|
Returns true if key is present in the given collection, otherwise
r |
2 ex. |
-
|
distinct?
|
Returns true if no two of the arguments are = |
1 ex. |
-
|
empty?
|
Returns true if coll has no items - same as (not (seq coll)).
Pleas |
3 ex. |
-
|
every?
|
Returns true if (pred x) is logical true for every x in coll, else
|
2 ex. |
-
|
not-every?
|
Returns false if (pred x) is logical true for every x in
coll, else |
1 ex. |
-
|
some
|
Returns the first logical true value of (pred x) for any x in coll,
|
7 ex. |
-
|
not-any?
|
Returns false if (pred x) is logical true for any x in coll,
else t |
1 ex. |
-
|
sequential?
|
Returns true if coll implements Sequential |
1 ex. |
-
|
associative?
|
Returns true if coll implements Associative |
0 ex. |
-
|
sorted?
|
Returns true if coll implements Sorted |
1 ex. |
-
|
counted?
|
Returns true if coll implements count in constant time |
1 ex. |
-
|
reversible?
|
Returns true if coll implements Reversible |
0 ex. |
-
|
coll?
|
Returns true if x implements IPersistentCollection |
2 ex. |
-
|
seq?
|
Return true if x implements ISeq |
1 ex. |
-
|
vector?
|
Return true if x implements IPersistentVector |
1 ex. |
-
|
list?
|
Returns true if x implements IPersistentList |
1 ex. |
-
|
map?
|
Return true if x implements IPersistentMap |
1 ex. |
-
|
set?
|
Returns true if x implements IPersistentSet |
1 ex. |
-
|
vec
|
Creates a new vector containing the contents of coll. |
1 ex. |
-
|
vector
|
Creates a new vector containing the args. |
3 ex. |
-
|
vector-of
|
Creates a new vector of a single primitive type t, where t is one
o |
1 ex. |
-
|
conj
|
conj[oin]. Returns a new collection with the xs
'added'. (conj ni |
1 ex. |
-
|
peek
|
For a list or queue, same as first, for a vector, same as, but much
|
1 ex. |
-
|
pop
|
For a list or queue, returns a new list/queue without the first
ite |
1 ex. |
-
|
get
|
Returns the value mapped to key, not-found or nil if key not present. |
1 ex. |
-
|
assoc
|
assoc[iate]. When applied to a map, returns a new map of the
same |
1 ex. |
-
|
subvec
|
Returns a persistent vector of the items in vector from
start (incl |
1 ex. |
-
|
rseq
|
Returns, in constant time, a seq of the items in rev (which
can be |
1 ex. |
-
|
list
|
Creates a new list containing the items. |
2 ex. |
-
|
list*
|
Creates a new list containing the items prepended to the rest, the
|
1 ex. |
-
|
cons
|
Returns a new seq where x is the first element and seq is
the res |
1 ex. |
-
|
conj
|
conj[oin]. Returns a new collection with the xs
'added'. (conj ni |
1 ex. |
-
|
peek
|
For a list or queue, same as first, for a vector, same as, but much
|
1 ex. |
-
|
pop
|
For a list or queue, returns a new list/queue without the first
ite |
1 ex. |
-
|
first
|
Returns the first item in the collection. Calls seq on its
argume |
2 ex. |
-
|
rest
|
Returns a possibly empty seq of the items after the first. Calls seq |
4 ex. |
-
|
hash-map
|
keyval => key val
Returns a new hash map with supplied mappings. |
2 ex. |
-
-
|
zipmap
|
Returns a map with the keys mapped to the corresponding vals. |
1 ex. |
-
|
sorted-map
|
keyval => key val
Returns a new sorted map with supplied mappings. |
1 ex. |
-
|
sorted-map-by
|
keyval => key val
Returns a new sorted map with supplied mappings, |
1 ex. |
-
|
bean
|
Takes a Java object and returns a read-only implementation of the
m |
1 ex. |
-
|
frequencies
|
Returns a map from distinct items in coll to the number of times
th |
1 ex. |
-
|
assoc
|
assoc[iate]. When applied to a map, returns a new map of the
same |
1 ex. |
-
|
assoc-in
|
Associates a value in a nested associative structure, where ks is a
|
1 ex. |
-
|
dissoc
|
dissoc[iate]. Returns a new map of the same (hashed/sorted) type,
t |
1 ex. |
-
|
find
|
Returns the map entry for key, or nil if key not present. |
2 ex. |
-
|
key
|
Returns the key of the map entry. |
1 ex. |
-
|
val
|
Returns the value in the map entry. |
3 ex. |
-
|
keys
|
Returns a sequence of the map's keys. |
1 ex. |
-
|
vals
|
Returns a sequence of the map's values. |
1 ex. |
-
|
get
|
Returns the value mapped to key, not-found or nil if key not present. |
1 ex. |
-
|
get-in
|
Returns the value in a nested associative structure,
where ks is a |
1 ex. |
-
|
update-in
|
'Updates' a value in a nested associative structure, where ks is a
|
3 ex. |
-
|
select-keys
|
Returns a map containing only those entries in map whose key is in ke |
1 ex. |
-
|
merge
|
Returns a map that consists of the rest of the maps conj-ed onto
th |
1 ex. |
-
|
merge-with
|
Returns a map that consists of the rest of the maps conj-ed onto
th |
3 ex. |
-
|
rseq
|
Returns, in constant time, a seq of the items in rev (which
can be |
1 ex. |
-
|
subseq
|
sc must be a sorted collection, test(s) one of <, <=, > or
>=. Retu |
1 ex. |
-
|
subseq
|
sc must be a sorted collection, test(s) one of <, <=, > or
>=. Retu |
1 ex. |
-
|
rsubseq
|
sc must be a sorted collection, test(s) one of <, <=, > or
>=. Retu |
1 ex. |
-
|
rsubseq
|
sc must be a sorted collection, test(s) one of <, <=, > or
>=. Retu |
1 ex. |
-
|
hash-set
|
Returns a new hash set with supplied keys. |
1 ex. |
-
|
set
|
Returns a set of the distinct elements of coll. |
2 ex. |
-
|
sorted-set
|
Returns a new sorted set with supplied keys. |
1 ex. |
-
|
sorted-set-by
|
Returns a new sorted set with supplied keys, using the supplied compa |
1 ex. |
-
|
conj
|
conj[oin]. Returns a new collection with the xs
'added'. (conj ni |
1 ex. |
-
|
disj
|
disj[oin]. Returns a new set of the same (hashed/sorted) type, that
|
1 ex. |
-
|
get
|
Returns the value mapped to key, not-found or nil if key not present. |
1 ex. |
-
|
defstruct
|
Same as (def name (create-struct keys...)) |
1 ex. |
-
-
|
struct
|
Returns a new structmap instance with the keys of the
structure-bas |
1 ex. |
-
|
struct-map
|
Returns a new structmap instance with the keys of the
structure-bas |
1 ex. |
-
|
accessor
|
Returns a fn that, given an instance of a structmap with the basis,
|
1 ex. |
-
|
get
|
Returns the value mapped to key, not-found or nil if key not present. |
1 ex. |
-
|
assoc
|
assoc[iate]. When applied to a map, returns a new map of the
same |
1 ex. |
-
|
seq
|
Returns a seq on the collection. If the collection is
empty, retu |
1 ex. |
-
|
sequence
|
Coerces coll to a (possibly empty) sequence, if it is not already
o |
1 ex. |
-
|
repeat
|
Returns a lazy (infinite!, or length n if supplied) sequence of xs. |
1 ex. |
-
-
|
range
|
Returns a lazy seq of nums from start (inclusive) to end
(exclusive |
2 ex. |
-
|
repeatedly
|
Takes a function of no args, presumably with side effects, and
retu |
2 ex. |
-
|
iterate
|
Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of |
3 ex. |
-
|
lazy-seq
|
Takes a body of expressions that returns an ISeq or nil, and yields
|
1 ex. |
-
|
lazy-cat
|
Expands to code which yields a lazy sequence of the concatenation
o |
1 ex. |
-
|
cycle
|
Returns a lazy (infinite!) sequence of repetitions of the items in co |
1 ex. |
-
|
interleave
|
Returns a lazy seq of the first item in each coll, then the second et |
3 ex. |
-
|
interpose
|
Returns a lazy seq of the elements of coll separated by sep |
1 ex. |
-
|
tree-seq
|
Returns a lazy sequence of the nodes in a tree, via a depth-first wal |
1 ex. |
-
|
xml-seq
|
A tree seq on the xml elements as per xml/parse |
0 ex. |
-
-
|
iterator-seq
|
Returns a seq on a java.util.Iterator. Note that most collections
p |
1 ex. |
-
|
file-seq
|
A tree seq on java.io.Files |
1 ex. |
-
|
line-seq
|
Returns the lines of text from rdr as a lazy sequence of strings.
r |
2 ex. |
-
|
resultset-seq
|
Creates and returns a lazy sequence of structmaps corresponding to
|
0 ex. |
-
|
first
|
Returns the first item in the collection. Calls seq on its
argume |
2 ex. |
-
|
second
|
Same as (first (next x)) |
1 ex. |
-
|
last
|
Return the last item in coll, in linear time |
2 ex. |
-
|
rest
|
Returns a possibly empty seq of the items after the first. Calls seq |
4 ex. |
-
|
next
|
Returns a seq of the items after the first. Calls seq on its
argume |
2 ex. |
-
|
ffirst
|
Same as (first (first x)) |
2 ex. |
-
|
nfirst
|
Same as (next (first x)) |
1 ex. |
-
|
fnext
|
Same as (first (next x)) |
1 ex. |
-
|
nnext
|
Same as (next (next x)) |
1 ex. |
-
|
nth
|
Returns the value at the index. get returns nil if index out of
bou |
1 ex. |
-
|
nthnext
|
Returns the nth next of coll, (seq coll) when n is 0. |
1 ex. |
-
|
rand-nth
|
Return a random element of the (sequential) collection. Will have
t |
1 ex. |
-
|
butlast
|
Return a seq of all but the last item in coll, in linear time |
2 ex. |
-
|
take
|
Returns a lazy sequence of the first n items in coll, or all items if |
2 ex. |
-
|
take-last
|
Returns a seq of the last n items in coll. Depending on the type
o |
1 ex. |
-
|
take-nth
|
Returns a lazy seq of every nth item in coll. |
1 ex. |
-
|
take-while
|
Returns a lazy sequence of successive items from coll while
(pred i |
1 ex. |
-
|
drop
|
Returns a lazy sequence of all but the first n items in coll. |
1 ex. |
-
|
drop-last
|
Return a lazy sequence of all but the last n (default 1) items in col |
1 ex. |
-
|
drop-while
|
Returns a lazy sequence of the items in coll starting from the first
|
1 ex. |
-
|
keep
|
Returns a lazy sequence of the non-nil results of (f item). Note,
t |
3 ex. |
-
|
keep-indexed
|
Returns a lazy sequence of the non-nil results of (f index item). Not |
3 ex. |
-
|
conj
|
conj[oin]. Returns a new collection with the xs
'added'. (conj ni |
1 ex. |
-
|
concat
|
Returns a lazy seq representing the concatenation of the elements in |
1 ex. |
-
|
distinct
|
Returns a lazy sequence of the elements of coll with duplicates remov |
2 ex. |
-
|
group-by
|
Returns a map of the elements of coll keyed by the result of
f on e |
2 ex. |
-
|
partition
|
Returns a lazy sequence of lists of n items each, at offsets step
a |
1 ex. |
-
|
partition-all
|
Returns a lazy sequence of lists like partition, but may include
pa |
1 ex. |
-
|
partition-by
|
Applies f to each value in coll, splitting it each time f returns
|
2 ex. |
-
|
split-at
|
Returns a vector of [(take n coll) (drop n coll)] |
1 ex. |
-
|
split-with
|
Returns a vector of [(take-while pred coll) (drop-while pred coll)] |
1 ex. |
-
|
filter
|
Returns a lazy sequence of the items in coll for which
(pred item) |
1 ex. |
-
|
remove
|
Returns a lazy sequence of the items in coll for which
(pred item) |
1 ex. |
-
|
replace
|
Given a map of replacement pairs and a vector/collection, returns a
|
2 ex. |
-
|
shuffle
|
Return a random permutation of coll |
1 ex. |
-
|
for
|
List comprehension. Takes a vector of one or more
binding-form/col |
6 ex. |
-
|
doseq
|
Repeatedly executes body (presumably for side-effects) with
binding |
5 ex. |
-
|
map
|
Returns a lazy sequence consisting of the result of applying f to the |
3 ex. |
-
|
map-indexed
|
Returns a lazy sequence consisting of the result of applying f to 0
|
1 ex. |
-
|
mapcat
|
Returns the result of applying concat to the result of applying map
|
1 ex. |
-
|
reduce
|
f should be a function of 2 arguments. If val is not supplied,
retu |
5 ex. |
-
|
reductions
|
Returns a lazy seq of the intermediate values of the reduction (as
|
1 ex. |
-
|
max-key
|
Returns the x for which (k x), a number, is greatest. |
1 ex. |
-
|
min-key
|
Returns the x for which (k x), a number, is least. |
2 ex. |
-
|
doall
|
When lazy sequences are produced via functions that have side
effec |
1 ex. |
-
|
dorun
|
When lazy sequences are produced via functions that have side
effec |
1 ex. |
-
|
transient
|
Alpha - subject to change.
Returns a new, transient version of the |
2 ex. |
-
|
persistent!
|
Alpha - subject to change.
Returns a new, persistent version of the |
1 ex. |
-
|
conj!
|
Alpha - subject to change.
Adds x to the transient collection, and |
1 ex. |
-
|
pop!
|
Alpha - subject to change.
Removes the last item from a transient v |
1 ex. |
-
|
assoc!
|
Alpha - subject to change.
When applied to a transient map, adds ma |
1 ex. |
-
|
dissoc!
|
Alpha - subject to change.
Returns a transient map that doesn't con |
1 ex. |
-
|
disj!
|
Alpha - subject to change.
disj[oin]. Returns a transient set of th |
1 ex. |
-
|
conj
|
conj[oin]. Returns a new collection with the xs
'added'. (conj ni |
1 ex. |
-
|
concat
|
Returns a lazy seq representing the concatenation of the elements in |
1 ex. |
-
|
distinct
|
Returns a lazy sequence of the elements of coll with duplicates remov |
2 ex. |
-
|
group-by
|
Returns a map of the elements of coll keyed by the result of
f on e |
2 ex. |
-
|
partition
|
Returns a lazy sequence of lists of n items each, at offsets step
a |
1 ex. |
-
|
partition-all
|
Returns a lazy sequence of lists like partition, but may include
pa |
1 ex. |
-
|
partition-by
|
Applies f to each value in coll, splitting it each time f returns
|
2 ex. |
-
|
split-at
|
Returns a vector of [(take n coll) (drop n coll)] |
1 ex. |
-
|
split-with
|
Returns a vector of [(take-while pred coll) (drop-while pred coll)] |
1 ex. |
-
|
filter
|
Returns a lazy sequence of the items in coll for which
(pred item) |
1 ex. |
-
|
remove
|
Returns a lazy sequence of the items in coll for which
(pred item) |
1 ex. |
-
|
replace
|
Given a map of replacement pairs and a vector/collection, returns a
|
2 ex. |
-
|
shuffle
|
Return a random permutation of coll |
1 ex. |
-
|
for
|
List comprehension. Takes a vector of one or more
binding-form/col |
6 ex. |
-
|
doseq
|
Repeatedly executes body (presumably for side-effects) with
binding |
5 ex. |
-
|
map
|
Returns a lazy sequence consisting of the result of applying f to the |
3 ex. |
-
|
map-indexed
|
Returns a lazy sequence consisting of the result of applying f to 0
|
1 ex. |
-
|
mapcat
|
Returns the result of applying concat to the result of applying map
|
1 ex. |
-
|
reduce
|
f should be a function of 2 arguments. If val is not supplied,
retu |
5 ex. |
-
|
reductions
|
Returns a lazy seq of the intermediate values of the reduction (as
|
1 ex. |
-
|
max-key
|
Returns the x for which (k x), a number, is greatest. |
1 ex. |
-
|
min-key
|
Returns the x for which (k x), a number, is least. |
2 ex. |
-
|
doall
|
When lazy sequences are produced via functions that have side
effec |
1 ex. |
-
|
dorun
|
When lazy sequences are produced via functions that have side
effec |
1 ex. |
-
|
def
|
Please see http://clojure.org/special_forms#def |
4 ex. |
-
|
defonce
|
defs name to have the root value of the expr iff the named var has no |
1 ex. |
-
|
intern
|
Finds or creates a var named by the symbol name in the namespace
ns |
1 ex. |
-
|
declare
|
defs the supplied var names with no bindings, useful for making forwa |
1 ex. |
-
|
set!
|
Please see http://clojure.org/special_forms#set |
1 ex. |
-
|
alter-var-root
|
Atomically alters the root binding of var v by applying f to its
cu |
1 ex. |
-
|
binding
|
binding => var-symbol init-expr
Creates new bindings for the (alre |
1 ex. |
-
|
with-bindings
|
Takes a map of Var/value pairs. Installs for the given Vars the assoc |
0 ex. |
-
|
with-bindings*
|
Takes a map of Var/value pairs. Installs for the given Vars the assoc |
0 ex. |
-
|
with-local-vars
|
varbinding=> symbol init-expr
Executes the exprs in a context in w |
0 ex. |
-
|
letfn
|
Takes a vector of function specs and a body, and generates a set of
|
1 ex. |
-
|
gensym
|
Returns a new symbol with a unique name. If a prefix string is
supp |
2 ex. |
-
|
var
|
Please see http://clojure.org/special_forms#var |
1 ex. |
-
|
find-var
|
Returns the global var named by the namespace-qualified symbol, or
|
0 ex. |
-
|
var-get
|
Gets the value in the var object |
0 ex. |
-
|
var?
|
Returns true if v is of type clojure.lang.Var |
1 ex. |
-
|
bound?
|
Returns true if all of the vars provided as arguments have any bound |
1 ex. |
-
|
resolve
|
same as (ns-resolve *ns* symbol) |
1 ex. |
-
|
ns-resolve
|
Returns the var or Class to which a symbol will be resolved in the
|
0 ex. |
-
-
|
ns
|
Sets *ns* to the namespace named by name (unevaluated), creating it
|
7 ex. |
-
|
create-ns
|
Create a new namespace named by the symbol if one doesn't already
e |
3 ex. |
-
|
remove-ns
|
Removes the namespace named by the symbol. Use with caution.
Cannot |
1 ex. |
-
|
*ns*
|
A clojure.lang.Namespace object representing the current namespace. |
1 ex. |
-
|
ns-name
|
Returns the name of the namespace, a symbol. |
0 ex. |
-
|
all-ns
|
Returns a sequence of all namespaces. |
1 ex. |
-
|
the-ns
|
If passed a namespace, returns it. Else, when passed a symbol,
retu |
1 ex. |
-
|
find-ns
|
Returns the namespace named by the symbol or nil if it doesn't exist. |
1 ex. |
-
|
ns-publics
|
Returns a map of the public intern mappings for the namespace. |
1 ex. |
-
|
ns-interns
|
Returns a map of the intern mappings for the namespace. |
1 ex. |
-
|
ns-refers
|
Returns a map of the refer mappings for the namespace. |
1 ex. |
-
|
ns-aliases
|
Returns a map of the aliases for the namespace. |
0 ex. |
-
|
ns-imports
|
Returns a map of the import mappings for the namespace. |
1 ex. |
-
|
ns-map
|
Returns a map of all the mappings for the namespace. |
1 ex. |
-
|
in-ns
|
Sets *ns* to the namespace named by the symbol, creating it if needed |
2 ex. |
-
|
ns-resolve
|
Returns the var or Class to which a symbol will be resolved in the
|
0 ex. |
-
|
ns-unalias
|
Removes the alias for the symbol from the namespace. |
0 ex. |
-
|
ns-unmap
|
Removes the mappings for the symbol from the namespace. |
1 ex. |
-
|
alias
|
Add an alias in the current namespace to another
namespace. Argumen |
1 ex. |
-
|
namespace-munge
|
Convert a Clojure namespace name to a legal Java package name. |
0 ex. |
-
-
|
make-hierarchy
|
Creates a hierarchy object for use with derive, isa? etc. |
1 ex. |
-
|
derive
|
Establishes a parent/child relationship between parent and
tag. Par |
2 ex. |
-
|
underive
|
Removes a parent/child relationship between parent and
tag. h must |
1 ex. |
-
|
parents
|
Returns the immediate parents of tag, either via a Java type
inheri |
1 ex. |
-
|
ancestors
|
Returns the immediate and indirect parents of tag, either via a Java |
2 ex. |
-
|
descendants
|
Returns the immediate and indirect children of tag, through a
relat |
1 ex. |
-
|
isa?
|
Returns true if (= child parent), or child is directly or indirectly |
2 ex. |
-
|
defprotocol
|
A protocol is a named set of named methods and their signatures:
(d |
2 ex. |
-
|
defrecord
|
Alpha - subject to change
(defrecord name [fields*] options* sp |
2 ex. |
-
|
deftype
|
Alpha - subject to change
(deftype name [fields*] options* spec |
1 ex. |
-
|
reify
|
reify is a macro with the following structure:
(reify options* spec |
1 ex. |
-
|
extend
|
Implementations of protocol methods can be provided using the extend |
1 ex. |
-
|
extend-protocol
|
Useful when you want to provide several implementations of the same
|
1 ex. |
-
|
extend-type
|
A macro that expands into an extend call. Useful when you are
suppl |
1 ex. |
-
|
extenders
|
Returns a collection of the types explicitly extending protocol |
0 ex. |
-
|
meta
|
Returns the metadata of obj, returns nil if there is no metadata. |
1 ex. |
-
|
with-meta
|
Returns an object of the same type and value as obj, with
map m a |
1 ex. |
-
|
vary-meta
|
Returns an object of the same type and value as obj, with
(apply f |
1 ex. |
-
|
reset-meta!
|
Atomically resets the metadata for a namespace/var/ref/agent/atom |
0 ex. |
-
|
alter-meta!
|
Atomically sets the metadata for a namespace/var/ref/agent/atom to be |
0 ex. |
-
|
use
|
Like 'require, but also refers to each lib's namespace using
clojur |
3 ex. |
-
|
require
|
Loads libs, skipping any that are already loaded. Each argument is
|
4 ex. |
-
|
import
|
import-list => (package-symbol class-name-symbols*)
For each name |
2 ex. |
-
-
|
refer
|
refers to all public vars of ns, subject to filters.
filters can in |
1 ex. |
-
-
|
*compile-path*
|
Specifies the directory where 'compile' will write out .class
files |
0 ex. |
-
|
*file*
|
The path of the file being evaluated, as a String.
Evaluates to ni |
0 ex. |
-
-
|
compile
|
Compiles the namespace named by the symbol lib into a set of
classf |
0 ex. |
-
|
load
|
Loads Clojure code from resources in classpath. A path is interpreted |
1 ex. |
-
|
load-file
|
Sequentially read and evaluate the set of forms contained in the file |
3 ex. |
-
|
load-reader
|
Sequentially read and evaluate the set of forms contained in the
st |
0 ex. |
-
|
load-string
|
Sequentially read and evaluate the set of forms contained in the
st |
0 ex. |
-
|
read
|
Reads the next object from stream, which must be an instance of
jav |
1 ex. |
-
-
|
gen-class
|
When compiling, generates compiled bytecode for a class with the
gi |
1 ex. |
-
|
gen-interface
|
When compiling, generates compiled bytecode for an interface with
t |
0 ex. |
-
|
loaded-libs
|
Returns a sorted set of symbols naming the currently loaded libs |
0 ex. |
-
|
test
|
test [v] finds fn at key :test in var metadata and calls it,
presum |
1 ex. |
-
|
*in*
|
A java.io.Reader object representing standard input for read operatio |
0 ex. |
-
|
*out*
|
A java.io.Writer object representing standard output for print operat |
0 ex. |
-
|
*err*
|
A java.io.Writer object representing standard error for print operati |
0 ex. |
-
|
print
|
Prints the object(s) to the output stream that is the current value
|
1 ex. |
-
|
printf
|
Prints formatted output, as per format |
1 ex. |
-
|
println
|
Same as print followed by (newline) |
1 ex. |
-
|
pr
|
Prints the object(s) to the output stream that is the current value
|
2 ex. |
-
|
prn
|
Same as pr followed by (newline). Observes *flush-on-newline* |
0 ex. |
-
|
print-str
|
print to a string, returning it |
1 ex. |
-
-
|
pr-str
|
pr to a string, returning it |
1 ex. |
-
|
prn-str
|
prn to a string, returning it |
1 ex. |
-
|
newline
|
Writes a newline to the output stream that is the current value of
|
0 ex. |
-
|
flush
|
Flushes the output stream that is the current value of
*out* |
0 ex. |
-
|
read-line
|
Reads the next line from stream that is the current value of *in* . |
1 ex. |
-
|
slurp
|
Reads the file named by f using the encoding enc into a string
and |
3 ex. |
-
|
spit
|
Opposite of slurp. Opens f with writer, writes content, then
close |
2 ex. |
-
|
with-in-str
|
Evaluates body in a context in which *in* is bound to a fresh
Strin |
1 ex. |
-
|
with-out-str
|
Evaluates exprs in a context in which *out* is bound to a fresh
Str |
1 ex. |
-
|
with-open
|
bindings => [name init ...]
Evaluates body in a try expression wit |
1 ex. |
-
|
*1
|
bound in a repl thread to the most recent value printed |
1 ex. |
-
|
*2
|
bound in a repl thread to the second most recent value printed |
1 ex. |
-
|
*3
|
bound in a repl thread to the third most recent value printed |
2 ex. |
-
|
*e
|
bound in a repl thread to the most recent exception caught by the rep |
1 ex. |
-
|
*print-dup*
|
When set to logical true, objects will be printed in a way that prese |
1 ex. |
-
|
*print-length*
|
*print-length* controls how many items of each collection the
print |
1 ex. |
-
|
*print-level*
|
*print-level* controls how many levels deep the printer will
print |
0 ex. |
-
|
*print-meta*
|
If set to logical true, when printing an object, its metadata will al |
0 ex. |
-
|
*print-readably*
|
When set to logical false, strings and characters will be printed wit |
0 ex. |
-
|
*clojure-version*
|
The version info for Clojure core, as a map containing :major :minor |
1 ex. |
-
-
-
|
time
|
Evaluates expr and prints the time it took. Returns the value of
ex |
2 ex. |