clojure quick reference clojuredocs - community-powered cl

Upload: peterjacob1

Post on 02-Jun-2018

236 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    1/28

    Simple Values

    Numbers > Arithmetic

    Numbers > Compare

    Quickref for Clojure Core

    Adapted from Johannes Friestad's excellent quick ref.

    Simple Values

    Numbers

    Arithmetic

    +

    Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +'

    -

    If no ys are supplied, returns the negation of x, else subtracts the ys from x and returns the result. Does

    *

    Returns the product of nums. (*) returns 1. Does not auto-promote longs, w ill throw on overflow. See also: *

    /

    If no denominators are supplied, returns 1/numerator, else returns numerator divided by all ofthe denominat

    quot

    quot[ient] of dividing numerator by denominator.

    rem

    remainder of dividing numerator by denominator.

    mod

    Modulus of num and div. Truncates toward negative infinity.

    incReturns a number one greater than num. Does not auto-promote longs, willthrow on overflow. See also: inc'

    dec

    Returns a number one less than num. Does not auto-promote longs, will throw on overflow. See also: dec'

    max

    Returns the greatest of the nums.

    min

    Returns the least of the nums.

    with-precision

    Sets the precision and rounding mode to be used for BigDecimal operations. Usage: (with-precision 10 (/ 1M

    Compare

    =

    Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, a

    ==

    Returns non-nil if nums all have the equivalent value (type-independent), otherwise false

    not=

    Same as (not (= obj1 obj2))

    Returns non-nil if nums are in monotonically decreasing order, otherwise false.

  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    2/28

    Numbers > Bitwise Operations

    Numbers > Cast

    Returns non-nil if nums are in monotonically non-decreasing order, otherwise false.

    >=

    Returns non-nil if nums are in monotonically non-increasing order, otherwise false.

    Bitwise Operations

    bit-and

    Bitwise and

    bit-orBitwise or

    bit-xor

    Bitwise exclusive or

    bit-flip

    Flip bit at index n

    bit-not

    Bitwise complement

    bit-clear

    Clear bit at index n

    bit-set

    Set bit at index n

    bit-shift-left

    Bitwise shift left

    bit-shift-right

    Bitwise shift right

    bit-test

    Test bit at index n

    Cast

    byte

    Coerce to byte

    short

    Coerce to short

    int

    Coerce to int

    long

    Coerce to long

    float

    Coerce to float

    double

    Coerce to double

    bigint

    Coerce to BigInt

    bigdec

    Coerce to BigDecimal

    num

    Coerce to Number

    rationalize

    returns the rational value of num

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 2 / 28

    http://clojuredocs.org/clojure.core/rationalizehttp://clojuredocs.org/clojure.core/numhttp://clojuredocs.org/clojure.core/bigdechttp://clojuredocs.org/clojure.core/biginthttp://clojuredocs.org/clojure.core/doublehttp://clojuredocs.org/clojure.core/floathttp://clojuredocs.org/clojure.core/longhttp://clojuredocs.org/clojure.core/inthttp://clojuredocs.org/clojure.core/shorthttp://clojuredocs.org/clojure.core/bytehttp://clojuredocs.org/clojure.core/bit-testhttp://clojuredocs.org/clojure.core/bit-shift-righthttp://clojuredocs.org/clojure.core/bit-shift-lefthttp://clojuredocs.org/clojure.core/bit-sethttp://clojuredocs.org/clojure.core/bit-clearhttp://clojuredocs.org/clojure.core/bit-nothttp://clojuredocs.org/clojure.core/bit-fliphttp://clojuredocs.org/clojure.core/bit-xorhttp://clojuredocs.org/clojure.core/bit-orhttp://clojuredocs.org/clojure.core/bit-andhttp://clojuredocs.org/clojure.core/%3E=
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    3/28

    Numbers > Test

    Simple Values

    Symbols / Keywords > Create

    Symbols / Keywords > Use

    Symbols / Keywords > Test

    Simple Values

    Strings / Characters > Create

    Test

    nil?

    Returns true if x is nil, false otherwise.

    identical?

    Tests if 2 arguments are the same object

    zero?

    Returns true if num is zero, else false

    pos?

    Returns true if num is greater than zero, else false

    neg?

    Returns true if num is less than zero, else false

    even?

    Returns true if n is even, throws an exception if n is not an integer

    odd?

    Returns true if n is odd, throws an exception if n is not an integer

    Symbols / Keywords

    Create

    keyword

    Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added

    symbol

    Returns a Symbol with the given namespace and name.

    Use

    name

    Returns the name String of a string, symbol or keyword.

    intern

    Finds or creates a var named by the symbol name in the namespace ns (which can be a symbol or a namespace),

    namespace

    Returns the namespace String of a symbol or keyword, or nil if not present.

    Test

    keyword?

    Return true if x is a Keyword

    symbol?

    Return true if x is a Symbol

    Strings / Characters

    Create

    str

    With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty s

    print-str

    print to a string, returning it

    println-str

    println to a string, returning it

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 3 / 28

    http://clojuredocs.org/clojure.core/println-strhttp://clojuredocs.org/clojure.core/print-strhttp://clojuredocs.org/clojure.core/strhttp://clojuredocs.org/clojure.core/symbol_qhttp://clojuredocs.org/clojure.core/keyword_qhttp://clojuredocs.org/clojure.core/namespacehttp://clojuredocs.org/clojure.core/internhttp://clojuredocs.org/clojure.core/namehttp://clojuredocs.org/clojure.core/symbolhttp://clojuredocs.org/clojure.core/keywordhttp://clojuredocs.org/clojure.core/odd_qhttp://clojuredocs.org/clojure.core/even_qhttp://clojuredocs.org/clojure.core/neg_qhttp://clojuredocs.org/clojure.core/pos_qhttp://clojuredocs.org/clojure.core/zero_qhttp://clojuredocs.org/clojure.core/identical_qhttp://clojuredocs.org/clojure.core/nil_q
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    4/28

    Strings / Characters > Use

    Strings / Characters > Cast / Test

    Simple Values

    Regular Expressions > Create

    Regular Expressions > Use

    Operations

    Flow Control > Normal

    pr-str

    pr to a string, returning it

    prn-str

    prn to a string, returning it

    with-out-str

    Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by

    Use

    count

    Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Ja

    get

    Returns the value mapped to key, not-found or nil if key not present.

    subs

    Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), e

    format

    Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax

    Cast / Test

    char

    Coerce to char

    char?

    Return true if x is a Character

    string?

    Return true if x is a String

    Regular Expressions

    Create

    re-pattern

    Returns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher.

    re-matcher

    Returns an instance of java.util.regex.Matcher, for use, e.g. in re-find.

    Use

    re-find

    Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-g

    re-matches

    Returns the match, if any, of string to pattern, using java.util.regex.Matcher.matches(). Uses re-groups to

    re-seq

    Returns a lazy sequence of successive matches of pattern in string, using java.util.regex.Matcher.find(), ea

    re-groups

    Returns the groups from the most recent match/find. If there are no nested groups, returns a string of the e

    Operations

    Flow Control

    Normal

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 4 / 28

    http://clojuredocs.org/clojure.core/re-groupshttp://clojuredocs.org/clojure.core/re-seqhttp://clojuredocs.org/clojure.core/re-matcheshttp://clojuredocs.org/clojure.core/re-findhttp://clojuredocs.org/clojure.core/re-matcherhttp://clojuredocs.org/clojure.core/re-patternhttp://clojuredocs.org/clojure.core/string_qhttp://clojuredocs.org/clojure.core/char_qhttp://clojuredocs.org/clojure.core/charhttp://clojuredocs.org/clojure.core/formathttp://clojuredocs.org/clojure.core/subshttp://clojuredocs.org/clojure.core/gethttp://clojuredocs.org/clojure.core/counthttp://clojuredocs.org/clojure.core/with-out-strhttp://clojuredocs.org/clojure.core/prn-strhttp://clojuredocs.org/clojure.core/pr-str
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    5/28

    Flow Control > Exceptional

    Flow Control > Delay

    if

    Evaluates test.

    if-not

    Evaluates test. If logical false, evaluates and returns then expr, otherwise else expr, if supplied, else n

    if-let

    bindings => binding-form test If test is true, evaluates then with binding-form bound to the value of te

    when

    Evaluates test. If logical true, evaluates body in an implicit do.

    when-not

    Evaluates test. If logical false, evaluates body in an implicit do.

    when-let

    bindings => binding-form test When test is true, evaluates body with binding-form bound to the value of tes

    when-first

    bindings => x xs Roughly the same as (when (seq xs) (let [x (first xs)] body)) but xs is evaluated only onc

    cond

    Takes a set of test/expr pairs. It evaluates each test one at a time. If a test returns logical true, cond

    condpTakes a binary predicate, an expression, and a set of clauses. Each clause can take the form of either: t

    case

    Takes an expression, and a set of clauses. Each clause can take the form of either: test-constant result

    do

    Evaluates the expressions in order and returns the value of the last. If no expressions are supplied, returns

    eval

    Evaluates the form data structure (not text!) and returns the result.

    loop

    Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respec

    recur

    Evaluates the exprs in order, then, in parallel, rebinds the bindings of the recursion point to the values of

    trampoline

    trampoline can be used to convert algorithms requiring mutual recursion without stack consumption. Calls f w

    while

    Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become

    Exceptional

    try

    The exprs are evaluated and, if no exceptions occur, the value of the last is returned. If an exception occurs

    catch

    The exprs are evaluated and, if no exceptions occur, the value of the last is returned. If an exception occurs

    finally

    The exprs are evaluated and, if no exceptions occur, the value of the last is returned. If an exception occurs

    throw

    Evaluates the exprs in order, then, in parallel, rebinds the bindings of the recursion point to the values of

    assert

    Evaluates expr and throws an exception if it does not evaluate to logical true.

    Delay

    delay

    Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is fo

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 5 / 28

    http://clojuredocs.org/clojure.core/delayhttp://clojuredocs.org/clojure.core/asserthttp://clojuredocs.org/clojure.core/throwhttp://clojuredocs.org/clojure.core/finallyhttp://clojuredocs.org/clojure.core/catchhttp://clojuredocs.org/clojure.core/tryhttp://clojuredocs.org/clojure.core/whilehttp://clojuredocs.org/clojure.core/trampolinehttp://clojuredocs.org/clojure.core/recurhttp://clojuredocs.org/clojure.core/loophttp://clojuredocs.org/clojure.core/evalhttp://clojuredocs.org/clojure.core/dohttp://clojuredocs.org/clojure.core/casehttp://clojuredocs.org/clojure.core/condphttp://clojuredocs.org/clojure.core/condhttp://clojuredocs.org/clojure.core/when-firsthttp://clojuredocs.org/clojure.core/when-lethttp://clojuredocs.org/clojure.core/when-nothttp://clojuredocs.org/clojure.core/whenhttp://clojuredocs.org/clojure.core/if-lethttp://clojuredocs.org/clojure.core/if-nothttp://clojuredocs.org/clojure.core/if
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    6/28

    Flow Control > Function Based

    Flow Control > Sequence Based

    Flow Control > Laziness

    Operations

    Type Inspection > Clojure Types

    Type Inspection > Java Types

    delay?

    returns true if x is a Delay created with delay

    deref

    Also reader macro: @ref/@agent/@var/@atom/@delay/@future/@promise. Within a transaction, returns the in-tran

    force

    If x is a Delay, returns the (possibly cached) value of its expression, else returns x

    Function Based

    repeatedly

    Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied)

    iterate

    Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects

    Sequence Based

    dotimes

    bindings => name n Repeatedly executes body (presumably for side-effects) with name bound to integers fro

    doseq

    Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by "for". Do

    for

    List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero

    Laziness

    lazy-seq

    Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the bo

    lazy-cat

    Expands to code which yields a lazy sequence of the concatenation of the supplied colls. Each coll expr is

    doallWhen lazy sequences are produced via functions that have side effects, any effects other than those needed t

    dorun

    When lazy sequences are produced via functions that have side effects, any effects other than those needed t

    Type Inspection

    Clojure Types

    type

    Returns the :type metadata of x, or its Class if none

    extends?

    Returns true if atype extends protocol

    satisfies?

    Returns true if x satisfies the protocol

    Java Types

    class

    Returns the Class of x

    basesReturns the immediate superclass and direct interfaces of c, if any

    supers

    Returns the immediate and indirect superclasses and interfaces of c, if any

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 6 / 28

    http://clojuredocs.org/clojure.core/supershttp://clojuredocs.org/clojure.core/baseshttp://clojuredocs.org/clojure.core/classhttp://clojuredocs.org/clojure.core/satisfies_qhttp://clojuredocs.org/clojure.core/extends_qhttp://clojuredocs.org/clojure.core/typehttp://clojuredocs.org/clojure.core/dorunhttp://clojuredocs.org/clojure.core/doallhttp://clojuredocs.org/clojure.core/lazy-cathttp://clojuredocs.org/clojure.core/lazy-seqhttp://clojuredocs.org/clojure.core/forhttp://clojuredocs.org/clojure.core/doseqhttp://clojuredocs.org/clojure.core/dotimeshttp://clojuredocs.org/clojure.core/iteratehttp://clojuredocs.org/clojure.core/repeatedlyhttp://clojuredocs.org/clojure.core/forcehttp://clojuredocs.org/clojure.core/derefhttp://clojuredocs.org/clojure.core/delay_q
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    7/28

    Operations

    Concurrency > General

    Concurrency > Atoms

    Concurrency > Refs

    class?

    Returns true if x is an instance of Class

    instance?

    Evaluates x and tests if it is an instance of the class c. Returns true or false

    isa?

    Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java

    cast

    Throws a ClassCastException if x is not a c, else returns x.

    Concurrency

    General

    deref

    Also reader macro: @ref/@agent/@var/@atom/@delay/@future/@promise. Within a transaction, returns the in-tran

    get-validator

    Gets the validator-fn for a var/ref/agent/atom.

    set-validator!

    Sets the validator-fn for a var/ref/agent/atom. validator-fn must be nil or a side-effect-free fn of one arg

    Atoms

    atom

    Creates and returns an Atom with an initial value of x and zero or more options (in any order): :meta met

    swap!

    Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called

    reset!

    Sets the value of atom to newval without regard for the current value. Returns newval.

    compare-and-set!

    Atomically sets the value of atom to newval if and only if the current value of the atom is identical to old

    Refs

    ref

    Creates and returns a Ref with an initial value of x and zero or more options (in any order): :meta metad

    sync

    transaction-flags => TBD, pass nil for now Runs the exprs (in an implicit do) in a transaction that encompa

    dosync

    Runs the exprs (in an implicit do) in a transaction that encompasses exprs and any nested calls. Starts a t

    ref-set

    Must be called in a transaction. Sets the value of ref. Returns val.

    alter

    Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value

    commute

    Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value

    ensure

    Must be called in a transaction. Protects the ref from modification by other transactions. Returns the in-t

    io!

    If an io! block occurs in a transaction, throws an IllegalStateException, else runs body in an implicit do.

    ref-history-count

    Returns the history count of a ref

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 7 / 28

    http://clojuredocs.org/clojure.core/ref-history-counthttp://clojuredocs.org/clojure.core/io!http://clojuredocs.org/clojure.core/ensurehttp://clojuredocs.org/clojure.core/commutehttp://clojuredocs.org/clojure.core/alterhttp://clojuredocs.org/clojure.core/ref-sethttp://clojuredocs.org/clojure.core/dosynchttp://clojuredocs.org/clojure.core/synchttp://clojuredocs.org/clojure.core/refhttp://clojuredocs.org/clojure.core/compare-and-set!http://clojuredocs.org/clojure.core/reset!http://clojuredocs.org/clojure.core/swap!http://clojuredocs.org/clojure.core/atomhttp://clojuredocs.org/clojure.core/set-validator!http://clojuredocs.org/clojure.core/get-validatorhttp://clojuredocs.org/clojure.core/derefhttp://clojuredocs.org/clojure.core/casthttp://clojuredocs.org/clojure.core/isa_qhttp://clojuredocs.org/clojure.core/instance_qhttp://clojuredocs.org/clojure.core/class_q
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    8/28

    Concurrency > Agents

    Concurrency > Futures

    ref-max-history

    Gets the max-history of a ref, or sets it and returns the ref

    ref-min-history

    Gets the min-history of a ref, or sets it and returns the ref

    Agents

    agent

    Creates and returns an agent with an initial value of state and zero or more options (in any order): :met

    send

    Dispatch an action to an agent. Returns the agent immediately. Subsequently, in a thread from a thread pool,

    send-off

    Dispatch a potentially blocking action to an agent. Returns the agent immediately. Subsequently, in a separa

    await

    Blocks the current thread (indefinitely!) until all actions dispatched thus far, from this thread or agent,

    await-for

    Blocks the current thread until all actions dispatched thus far (from this thread or agent) to the agents ha

    agent-error

    Returns the exception thrown during an asynchronous action of the agent if the agent is failed. Returns nil

    restart-agent

    When an agent is failed, changes the agent state to new-state and then un-fails the agent so that sends are

    shutdown-agents

    Initiates a shutdown of the thread pools that back the agent system. Running actions will complete, but no n

    *agent*

    The agent currently running an action on this thread, else nil

    error-handler

    Returns the error-handler of agent a, or nil if there is none. See set-error-handler!

    set-error-handler!

    Sets the error-handler of agent a to handler-fn. If an action being run by the agent throws an exception or

    error-mode

    Returns the error-mode of agent a. See set-error-mode!

    set-error-mode!

    Sets the error-mode of agent a to mode-keyword, which must be either :fail or :continue. If an action being

    release-pending-sends

    Normally, actions sent directly or indirectly during another action are held until the action completes (cha

    Futures

    future

    Takes a body of expressions and yields a future object that will invoke the body in another thread, and will

    future-call

    Takes a function of no args and yields a future object that will invoke the function in another thread, and

    future-done?

    Returns true if future f is done

    future-cancel

    Cancels the future, if possible.

    future-cancelled?

    Returns true if future f is cancelled

    future?

    Returns true if x is a future

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 8 / 28

    http://clojuredocs.org/clojure.core/future_qhttp://clojuredocs.org/clojure.core/future-cancelled_qhttp://clojuredocs.org/clojure.core/future-cancelhttp://clojuredocs.org/clojure.core/future-done_qhttp://clojuredocs.org/clojure.core/future-callhttp://clojuredocs.org/clojure.core/futurehttp://clojuredocs.org/clojure.core/release-pending-sendshttp://clojuredocs.org/clojure.core/set-error-mode!http://clojuredocs.org/clojure.core/error-modehttp://clojuredocs.org/clojure.core/set-error-handler!http://clojuredocs.org/clojure.core/error-handlerhttp://clojuredocs.org/clojure.core/*agent*http://clojuredocs.org/clojure.core/shutdown-agentshttp://clojuredocs.org/clojure.core/restart-agenthttp://clojuredocs.org/clojure.core/agent-errorhttp://clojuredocs.org/clojure.core/await-forhttp://clojuredocs.org/clojure.core/awaithttp://clojuredocs.org/clojure.core/send-offhttp://clojuredocs.org/clojure.core/sendhttp://clojuredocs.org/clojure.core/agenthttp://clojuredocs.org/clojure.core/ref-min-historyhttp://clojuredocs.org/clojure.core/ref-max-history
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    9/28

    Concurrency > Thread Local Values

    Concurrency > Misc

    Functions

    General > Create

    Thread Local Values

    bound-fn

    Returns a function defined by the given fntail, which will install the same bindings in effect as in the thr

    bound-fn*

    Returns a function, which will install the same bindings in effect as in the thread at the time bound-fn* wa

    get-thread-bindings

    Get a map with the Var/value pairs which is currently in effect for the current thread.

    push-thread-bindings

    WARNING: This is a low-level function. Prefer high-level macros like binding where ever possible. Takes a

    pop-thread-bindings

    Pop one set of bindings pushed with push-binding before. It is an error to pop bindings without pushing befo

    thread-bound?

    Returns true if all of the vars provided as arguments have thread-local bindings. Implies that set!'ing the

    Misc

    locking

    Executes exprs in an implicit do, while holding the monitor of x. Will release the monitor of x in all circu

    pcalls

    Executes the no-arg fns in parallel, returning a lazy sequence of their values

    pvalues

    Returns a lazy sequence of the values of the exprs, which are evaluated in parallel

    pmap

    Like map, except f is applied in parallel. Semi-lazy in that the parallel computation stays ahead of the con

    seque

    Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the b

    promiseReturns a promise object that can be read with deref/@, and set, once only, with deliver. Calls to deref/@ p

    deliver

    Delivers the supplied value to the promise, releasing any pending derefs. A subsequent call to deliver on a

    add-watch

    Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the re

    remove-watch

    Removes a watch (set by add-watch) from a reference

    Functions

    General

    Create

    fn

    params => positional-params* , or positional-params* & next-param positional-param => binding-form next-pa

    defn

    Same as (def name (fn [params* ] exprs*)) or (def name (fn ([params* ] exprs*)+)) with any doc-string or a

    defn-

    same as defn, yielding non-public def

    definline

    Experimental - like defmacro, except defines a named function whose body is the expansion, calls to which ma

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 9 / 28

    http://clojuredocs.org/clojure.core/definlinehttp://clojuredocs.org/clojure.core/defn-http://clojuredocs.org/clojure.core/defnhttp://clojuredocs.org/clojure.core/fnhttp://clojuredocs.org/clojure.core/remove-watchhttp://clojuredocs.org/clojure.core/add-watchhttp://clojuredocs.org/clojure.core/deliverhttp://clojuredocs.org/clojure.core/promisehttp://clojuredocs.org/clojure.core/sequehttp://clojuredocs.org/clojure.core/pmaphttp://clojuredocs.org/clojure.core/pvalueshttp://clojuredocs.org/clojure.core/pcallshttp://clojuredocs.org/clojure.core/lockinghttp://clojuredocs.org/clojure.core/thread-bound_qhttp://clojuredocs.org/clojure.core/pop-thread-bindingshttp://clojuredocs.org/clojure.core/push-thread-bindingshttp://clojuredocs.org/clojure.core/get-thread-bindingshttp://clojuredocs.org/clojure.core/bound-fn*http://clojuredocs.org/clojure.core/bound-fn
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    10/28

    General > Call

    General > Test

    Functions

    Multifunctions > Create

    Multifunctions > Inspect and Modify

    identity

    Returns its argument.

    constantly

    Returns a function that takes any number of arguments and returns x.

    memfn

    Expands into code that creates a fn that expects to be passed an object and any args and calls the named ins

    comp

    Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a var

    complement

    Takes a fn f and returns a fn that takes the same arguments as f, has the same effects, if any, and returns

    partial

    Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number o

    juxt

    Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a v

    memoize

    Returns a memoized version of a referentially transparent function. The memoized version of the function kee

    Call

    ->

    Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if i

    ->>

    Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it

    apply

    Applies fn f to the argument list formed by prepending intervening arguments to args.

    Test

    fn?

    Returns true if x implements Fn, i.e. is an object created via fn.

    ifn?

    Returns true if x implements IFn. Note that many data structures (e.g. sets and maps) implement IFn

    Multifunctions

    Create

    defmulti

    Creates a new multimethod with the associated dispatch function. The docstring and attribute-map are optiona

    defmethod

    Creates and installs a new method of multimethod associated with dispatch-value.

    Inspect and Modify

    get-method

    Given a multimethod and a dispatch value, returns the dispatch fn that would apply to that value, or nil if

    methods

    Given a multimethod, returns a map of dispatch values -> dispatch fns

    prefer-method

    Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y when there is a conflict

    prefers

    Given a multimethod, returns a map of preferred value -> set of other values

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 10 / 28

    http://clojuredocs.org/clojure.core/prefershttp://clojuredocs.org/clojure.core/prefer-methodhttp://clojuredocs.org/clojure.core/methodshttp://clojuredocs.org/clojure.core/get-methodhttp://clojuredocs.org/clojure.core/defmethodhttp://clojuredocs.org/clojure.core/defmultihttp://clojuredocs.org/clojure.core/ifn_qhttp://clojuredocs.org/clojure.core/fn_qhttp://clojuredocs.org/clojure.core/applyhttp://clojuredocs.org/clojure.core/-%3E%3Ehttp://clojuredocs.org/clojure.core/-%3Ehttp://clojuredocs.org/clojure.core/memoizehttp://clojuredocs.org/clojure.core/juxthttp://clojuredocs.org/clojure.core/partialhttp://clojuredocs.org/clojure.core/complementhttp://clojuredocs.org/clojure.core/comphttp://clojuredocs.org/clojure.core/memfnhttp://clojuredocs.org/clojure.core/constantlyhttp://clojuredocs.org/clojure.core/identity
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    11/28

    Functions

    Macros > Create

    Functions

    Java Interop > Objects

    Java Interop > Array Creation

    remove-method

    Removes the method of multimethod associated with dispatch-value.

    remove-all-methods

    Removes all of the methods of multimethod.

    Macros

    Create

    defmacro

    Like defn, but the resulting function name is declared as a macro and will be used as a macro by the compile

    macroexpand

    Repeatedly calls macroexpand-1 on form until it no longer represents a macro form, then returns it. Note ne

    macroexpand-1

    If form represents a macro form, returns its expansion, else returns form.

    gensym

    Returns a new symbol with a unique name. If a prefix string is supplied, the name is prefix# where # is some

    Java Interop

    Objects

    doto

    Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the giv

    ..

    form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first

    set!

    Assignment special form. When the first operand is a field member access form, the assignment is to the corres

    Array Creation

    make-array

    Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a

    object-array

    Creates an array of objects

    boolean-array

    Creates an array of booleans

    byte-array

    Creates an array of bytes

    char-array

    Creates an array of chars

    short-array

    Creates an array of shorts

    int-array

    Creates an array of ints

    long-array

    Creates an array of longs

    float-array

    Creates an array of floats

    double-array

    Creates an array of doubles

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 11 / 28

    http://clojuredocs.org/clojure.core/double-arrayhttp://clojuredocs.org/clojure.core/float-arrayhttp://clojuredocs.org/clojure.core/long-arrayhttp://clojuredocs.org/clojure.core/int-arrayhttp://clojuredocs.org/clojure.core/short-arrayhttp://clojuredocs.org/clojure.core/char-arrayhttp://clojuredocs.org/clojure.core/byte-arrayhttp://clojuredocs.org/clojure.core/boolean-arrayhttp://clojuredocs.org/clojure.core/object-arrayhttp://clojuredocs.org/clojure.core/make-arrayhttp://clojuredocs.org/clojure.core/set!http://clojuredocs.org/clojure.core/_..http://clojuredocs.org/clojure.core/dotohttp://clojuredocs.org/clojure.core/gensymhttp://clojuredocs.org/clojure.core/macroexpand-1http://clojuredocs.org/clojure.core/macroexpandhttp://clojuredocs.org/clojure.core/defmacrohttp://clojuredocs.org/clojure.core/remove-all-methodshttp://clojuredocs.org/clojure.core/remove-method
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    12/28

    Java Interop > Array Use

    Java Interop > Casting

    aclone

    Returns a clone of the Java array. Works on arrays of known types.

    to-array

    Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util

    to-array-2d

    Returns a (potentially-ragged) 2-dimensional array of Objects containing the contents of coll, which can be

    into-array

    Returns an array with components set to the values in aseq. The array's component type is type if provided,

    Array Use

    aget

    Returns the value at the index/indices. Works on Java arrays of all types.

    aset

    Sets the value at the index/indices. Works on Java arrays of reference types. Returns val.

    aset-boolean

    Sets the value at the index/indices. Works on arrays of boolean. Returns val.

    aset-char

    Sets the value at the index/indices. Works on arrays of char. Returns val.

    aset-byte

    Sets the value at the index/indices. Works on arrays of byte. Returns val.

    aset-int

    Sets the value at the index/indices. Works on arrays of int. Returns val.

    aset-long

    Sets the value at the index/indices. Works on arrays of long. Returns val.

    aset-short

    Sets the value at the index/indices. Works on arrays of short. Returns val.

    aset-float

    Sets the value at the index/indices. Works on arrays of float. Returns val.

    aset-double

    Sets the value at the index/indices. Works on arrays of double. Returns val.

    alength

    Returns the length of the Java array. Works on arrays of all types.

    amap

    Maps an expression across an array a, using an index named idx, and return value named ret, initialized to a

    areduce

    Reduces an expression across an array a, using an index named idx, and return value named ret, initialized t

    Casting

    booleans

    Casts to boolean[]

    bytes

    Casts to bytes[]

    chars

    Casts to chars[]

    ints

    Casts to int[]

    shorts

    Casts to shorts[]

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 12 / 28

    http://clojuredocs.org/clojure.core/shortshttp://clojuredocs.org/clojure.core/intshttp://clojuredocs.org/clojure.core/charshttp://clojuredocs.org/clojure.core/byteshttp://clojuredocs.org/clojure.core/booleanshttp://clojuredocs.org/clojure.core/areducehttp://clojuredocs.org/clojure.core/amaphttp://clojuredocs.org/clojure.core/alengthhttp://clojuredocs.org/clojure.core/aset-doublehttp://clojuredocs.org/clojure.core/aset-floathttp://clojuredocs.org/clojure.core/aset-shorthttp://clojuredocs.org/clojure.core/aset-longhttp://clojuredocs.org/clojure.core/aset-inthttp://clojuredocs.org/clojure.core/aset-bytehttp://clojuredocs.org/clojure.core/aset-charhttp://clojuredocs.org/clojure.core/aset-booleanhttp://clojuredocs.org/clojure.core/asethttp://clojuredocs.org/clojure.core/agethttp://clojuredocs.org/clojure.core/into-arrayhttp://clojuredocs.org/clojure.core/to-array-2dhttp://clojuredocs.org/clojure.core/to-arrayhttp://clojuredocs.org/clojure.core/aclone
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    13/28

    Functions

    Proxies > Create

    Prox ies > Misc

    Collections

    Collections > Generic Operations

    Collections > Content Tests

    longs

    Casts to long[]

    floats

    Casts to float[]

    doubles

    Casts to double[]

    Proxies

    Create

    proxy

    class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the supercl

    get-proxy-class

    Takes an optional single class followed by zero or more interfaces. If not supplied class defaults to Object

    construct-proxy

    Takes a proxy class and any arguments for its superclass ctor and creates and returns an instance of the pro

    init-proxy

    Takes a proxy instance and a map of strings (which must correspond to methods of the proxy superclass/superi

    Misc

    proxy-mappings

    Takes a proxy instance and returns the proxy's fn map.

    proxy-super

    Use to call a superclass method in the body of a proxy method. Note, expansion captures 'this

    update-proxy

    Takes a proxy instance and a map of strings (which must correspond to methods of the proxy superclass/superi

    Collections

    Collections

    Generic Operations

    count

    Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Ja

    empty

    Returns an empty collection of the same category as coll, or nil

    not-empty

    If coll is empty, returns nil, else coll

    into

    Returns a new coll consisting of to-coll with all of the items of from-coll conjoined.

    conj

    conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' m

    Content Tests

    contains?

    Returns true if key is present in the given collection, otherwise returns false. Note that for numerically

    distinct?

    Returns true if no two of the arguments are =

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 13 / 28

    http://clojuredocs.org/clojure.core/distinct_qhttp://clojuredocs.org/clojure.core/contains_qhttp://clojuredocs.org/clojure.core/conjhttp://clojuredocs.org/clojure.core/intohttp://clojuredocs.org/clojure.core/not-emptyhttp://clojuredocs.org/clojure.core/emptyhttp://clojuredocs.org/clojure.core/counthttp://clojuredocs.org/clojure.core/update-proxyhttp://clojuredocs.org/clojure.core/proxy-superhttp://clojuredocs.org/clojure.core/proxy-mappingshttp://clojuredocs.org/clojure.core/init-proxyhttp://clojuredocs.org/clojure.core/construct-proxyhttp://clojuredocs.org/clojure.core/get-proxy-classhttp://clojuredocs.org/clojure.core/proxyhttp://clojuredocs.org/clojure.core/doubleshttp://clojuredocs.org/clojure.core/floatshttp://clojuredocs.org/clojure.core/longs
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    14/28

    Collections > Capabilities

    Collections > Type Tests

    Collections

    Vectors > Create

    Vectors > Use

    empty?

    Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not

    every?

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

    not-every?

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

    some

    Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a

    not-any?

    Returns false if (pred x) is logical true for any x in coll, else true.

    Capabilities

    sequential?

    Returns true if coll implements Sequential

    associative?

    Returns true if coll implements Associative

    sorted?

    Returns true if coll implements Sorted

    counted?

    Returns true if coll implements count in constant time

    reversible?

    Returns true if coll implements Reversible

    Type Tests

    coll?

    Returns true if x implements IPersistentCollection

    seq?

    Return true if x implements ISeq

    vector?

    Return true if x implements IPersistentVector

    list?

    Returns true if x implements IPersistentList

    map?

    Return true if x implements IPersistentMap

    set?Returns true if x implements IPersistentSet

    Vectors

    Create

    vec

    Creates a new vector containing the contents of coll. Java arrays will be aliased and should not be modified

    vector

    Creates a new vector containing the args.

    vector-of

    Creates a new vector of a single primitive type t, where t is one of :int :long :float :double :byte :short

    Use

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 14 / 28

    http://clojuredocs.org/clojure.core/vector-ofhttp://clojuredocs.org/clojure.core/vectorhttp://clojuredocs.org/clojure.core/vechttp://clojuredocs.org/clojure.core/set_qhttp://clojuredocs.org/clojure.core/map_qhttp://clojuredocs.org/clojure.core/list_qhttp://clojuredocs.org/clojure.core/vector_qhttp://clojuredocs.org/clojure.core/seq_qhttp://clojuredocs.org/clojure.core/coll_qhttp://clojuredocs.org/clojure.core/reversible_qhttp://clojuredocs.org/clojure.core/counted_qhttp://clojuredocs.org/clojure.core/sorted_qhttp://clojuredocs.org/clojure.core/associative_qhttp://clojuredocs.org/clojure.core/sequential_qhttp://clojuredocs.org/clojure.core/not-any_qhttp://clojuredocs.org/clojure.core/somehttp://clojuredocs.org/clojure.core/not-every_qhttp://clojuredocs.org/clojure.core/every_qhttp://clojuredocs.org/clojure.core/empty_q
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    15/28

    Collections

    Lists > Create

    Lists > Use

    Collections

    Maps > Create

    conj

    conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' m

    peek

    For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collec

    pop

    For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector wit

    get

    Returns the value mapped to key, not-found or nil if key not present.

    assoc

    assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the

    subvec

    Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not

    rseq

    Returns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order

    Lists

    Create

    list

    Creates a new list containing the items.

    list*

    Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequen

    Use

    cons

    Returns a new seq where x is the first element and seq is the rest.

    conj

    conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' m

    peek

    For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collec

    pop

    For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector wit

    first

    Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil.

    rest

    Returns a possibly empty seq of the items after the first. Calls seq on its argument.

    Maps

    Create

    hash-map

    keyval => key val Returns a new hash map with supplied mappings. If any keys are equal, they are handled

    array-mapConstructs an array-map. If any keys are equal, they are handled as if by repeated uses of assoc.

    zipmap

    Returns a map with the keys mapped to the corresponding vals.

    sorted-map

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 15 / 28

    http://clojuredocs.org/clojure.core/sorted-maphttp://clojuredocs.org/clojure.core/zipmaphttp://clojuredocs.org/clojure.core/array-maphttp://clojuredocs.org/clojure.core/hash-maphttp://clojuredocs.org/clojure.core/resthttp://clojuredocs.org/clojure.core/firsthttp://clojuredocs.org/clojure.core/pophttp://clojuredocs.org/clojure.core/peekhttp://clojuredocs.org/clojure.core/conjhttp://clojuredocs.org/clojure.core/conshttp://clojuredocs.org/clojure.core/list*http://clojuredocs.org/clojure.core/listhttp://clojuredocs.org/clojure.core/rseqhttp://clojuredocs.org/clojure.core/subvechttp://clojuredocs.org/clojure.core/assochttp://clojuredocs.org/clojure.core/gethttp://clojuredocs.org/clojure.core/pophttp://clojuredocs.org/clojure.core/peekhttp://clojuredocs.org/clojure.core/conj
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    16/28

    Maps > Use (Sorted Maps)

    Maps > Use

    keyval => key val Returns a new sorted map with supplied mappings. If any keys are equal, they are handle

    sorted-map-by

    keyval => key val Returns a new sorted map with supplied mappings, using the supplied comparator. If any

    bean

    Takes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean pr

    frequencies

    Returns a map from distinct items in coll to the number of times they appear.

    Use (Sorted Maps)

    assoc

    assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the

    assoc-in

    Associates a value in a nested associative structure, where ks is a sequence of keys and v is the new value

    dissoc

    dissoc[iate]. Returns a new map of the same (hashed/sorted) type, that does not contain a mapping for key(s)

    find

    Returns the map entry for key, or nil if key not present.

    key

    Returns the key of the map entry.

    val

    Returns the value in the map entry.

    keys

    Returns a sequence of the map's keys, in the same order as (seq map).

    vals

    Returns a sequence of the map's values, in the same order as (seq map).

    getReturns the value mapped to key, not-found or nil if key not present.

    get-in

    Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key

    update-in

    'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that

    select-keys

    Returns a map containing only those entries in map whose key is in keys

    merge

    Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than on

    merge-with

    Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than on

    Use

    rseq

    Returns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order

    subseq

    sc must be a sorted collection, test(s) one of =. Returns a seq of those entries with keys ek f

    subseq

    sc must be a sorted collection, test(s) one of =. Returns a seq of those entries with keys ek f

    rsubseq

    sc must be a sorted collection, test(s) one of =. Returns a reverse seq of those entries with k

    rsubseq

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 16 / 28

    http://clojuredocs.org/clojure.core/rsubseqhttp://clojuredocs.org/clojure.core/rsubseqhttp://clojuredocs.org/clojure.core/subseqhttp://clojuredocs.org/clojure.core/subseqhttp://clojuredocs.org/clojure.core/rseqhttp://clojuredocs.org/clojure.core/merge-withhttp://clojuredocs.org/clojure.core/mergehttp://clojuredocs.org/clojure.core/select-keyshttp://clojuredocs.org/clojure.core/update-inhttp://clojuredocs.org/clojure.core/get-inhttp://clojuredocs.org/clojure.core/gethttp://clojuredocs.org/clojure.core/valshttp://clojuredocs.org/clojure.core/keyshttp://clojuredocs.org/clojure.core/valhttp://clojuredocs.org/clojure.core/keyhttp://clojuredocs.org/clojure.core/findhttp://clojuredocs.org/clojure.core/dissochttp://clojuredocs.org/clojure.core/assoc-inhttp://clojuredocs.org/clojure.core/assochttp://clojuredocs.org/clojure.core/frequencieshttp://clojuredocs.org/clojure.core/beanhttp://clojuredocs.org/clojure.core/sorted-map-by
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    17/28

    Collections

    Sets > Create

    Sets > Use

    Collections

    Structs > Create

    Structs > Use

    Collections

    Sequences > Create

    sc must be a sorted collection, test(s) one of =. Returns a reverse seq of those entries with k

    Sets

    Create

    hash-set

    Returns a new hash set with supplied keys. Any equal keys are handled as if by repeated uses of conj.

    set

    Returns a set of the distinct elements of coll.

    sorted-set

    Returns a new sorted set with supplied keys. Any equal keys are handled as if by repeated uses of conj.

    sorted-set-by

    Returns a new sorted set with supplied keys, using the supplied comparator. Any equal keys are handled as i

    Use

    conj

    conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' m

    disj

    disj[oin]. Returns a new set of the same (hashed/sorted) type, that does not contain key(s).

    get

    Returns the value mapped to key, not-found or nil if key not present.

    Structs

    Create

    defstruct

    Same as (def name (create-struct keys...))

    create-struct

    Returns a structure basis object.

    struct

    Returns a new structmap instance with the keys of the structure-basis. vals must be supplied for basis keys

    struct-map

    Returns a new structmap instance with the keys of the structure-basis. keyvals may contain all, some or none

    accessor

    Returns a fn that, given an instance of a structmap with the basis, returns the value at the key. The key m

    Use

    get

    Returns the value mapped to key, not-found or nil if key not present.

    assoc

    assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the

    Sequences

    Create

    seq

    Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 17 / 28

    http://clojuredocs.org/clojure.core/seqhttp://clojuredocs.org/clojure.core/assochttp://clojuredocs.org/clojure.core/gethttp://clojuredocs.org/clojure.core/accessorhttp://clojuredocs.org/clojure.core/struct-maphttp://clojuredocs.org/clojure.core/structhttp://clojuredocs.org/clojure.core/create-structhttp://clojuredocs.org/clojure.core/defstructhttp://clojuredocs.org/clojure.core/gethttp://clojuredocs.org/clojure.core/disjhttp://clojuredocs.org/clojure.core/conjhttp://clojuredocs.org/clojure.core/sorted-set-byhttp://clojuredocs.org/clojure.core/sorted-sethttp://clojuredocs.org/clojure.core/sethttp://clojuredocs.org/clojure.core/hash-set
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    18/28

    Sequences > Use (General)

    sequence

    Coerces coll to a (possibly empty) sequence, if it is not already one. Will not force a lazy seq. (sequence

    repeat

    Returns a lazy (infinite!, or length n if supplied) sequence of xs.

    replicate

    DEPRECATED: Use 'repeat' instead. Returns a lazy seq of n xs.

    range

    Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, st

    repeatedly

    Takes a function of no args, presumably with side effects, and returns an infinite (or length n if supplied)

    iterate

    Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects

    lazy-seq

    Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the bo

    lazy-cat

    Expands to code which yields a lazy sequence of the concatenation of the supplied colls. Each coll expr is

    cycleReturns a lazy (infinite!) sequence of repetitions of the items in coll.

    interleave

    Returns a lazy seq of the first item in each coll, then the second etc.

    interpose

    Returns a lazy seq of the elements of coll separated by sep

    tree-seq

    Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg tha

    xml-seq

    A tree seq on the xml elements as per xml/parse

    enumeration-seq

    Returns a seq on a java.util.Enumeration

    iterator-seq

    Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and

    file-seq

    A tree seq on java.io.Files

    line-seq

    Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader.

    resultset-seqCreates and returns a lazy sequence of structmaps corresponding to the rows in the java.sql.ResultSet rs

    Use (General)

    first

    Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil.

    second

    Same as (first (next x))

    last

    Return the last item in coll, in linear time

    rest

    Returns a possibly empty seq of the items after the first. Calls seq on its argument.

    next

    Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 18 / 28

    http://clojuredocs.org/clojure.core/nexthttp://clojuredocs.org/clojure.core/resthttp://clojuredocs.org/clojure.core/lasthttp://clojuredocs.org/clojure.core/secondhttp://clojuredocs.org/clojure.core/firsthttp://clojuredocs.org/clojure.core/resultset-seqhttp://clojuredocs.org/clojure.core/line-seqhttp://clojuredocs.org/clojure.core/file-seqhttp://clojuredocs.org/clojure.core/iterator-seqhttp://clojuredocs.org/clojure.core/enumeration-seqhttp://clojuredocs.org/clojure.core/xml-seqhttp://clojuredocs.org/clojure.core/tree-seqhttp://clojuredocs.org/clojure.core/interposehttp://clojuredocs.org/clojure.core/interleavehttp://clojuredocs.org/clojure.core/cyclehttp://clojuredocs.org/clojure.core/lazy-cathttp://clojuredocs.org/clojure.core/lazy-seqhttp://clojuredocs.org/clojure.core/iteratehttp://clojuredocs.org/clojure.core/repeatedlyhttp://clojuredocs.org/clojure.core/rangehttp://clojuredocs.org/clojure.core/replicatehttp://clojuredocs.org/clojure.core/repeathttp://clojuredocs.org/clojure.core/sequence
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    19/28

    Sequences > Use ('Modification')

    ffirst

    Same as (first (first x))

    nfirst

    Same as (next (first x))

    fnext

    Same as (first (next x))

    nnext

    Same as (next (next x))

    nth

    Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-f

    nthnext

    Returns the nth next of coll, (seq coll) when n is 0.

    rand-nth

    Return a random element of the (sequential) collection. Will have the same performance characteristics as nt

    butlast

    Return a seq of all but the last item in coll, in linear time

    takeReturns a lazy sequence of the first n items in coll, or all items if there are fewer than n.

    take-last

    Returns a seq of the last n items in coll. Depending on the type of coll may be no better than linear time.

    take-nth

    Returns a lazy seq of every nth item in coll.

    take-while

    Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of s

    drop

    Returns a lazy sequence of all but the first n items in coll.

    drop-last

    Return a lazy sequence of all but the last n (default 1) items in coll

    drop-while

    Returns a lazy sequence of the items in coll starting from the first item for which (pred item) returns logi

    keep

    Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be inc

    keep-indexed

    Returns a lazy sequence of the non-nil results of (f index item). Note, this means false return values will

    Use ('Modification')

    conj

    conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' m

    concat

    Returns a lazy seq representing the concatenation of the elements in the supplied colls.

    distinct

    Returns a lazy sequence of the elements of coll with duplicates removed

    group-by

    Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will b

    partition

    Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults t

    partition-all

    Returns a lazy sequence of lists like partition, but may include partitions with fewer than n items at the e

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 19 / 28

    http://clojuredocs.org/clojure.core/partition-allhttp://clojuredocs.org/clojure.core/partitionhttp://clojuredocs.org/clojure.core/group-byhttp://clojuredocs.org/clojure.core/distincthttp://clojuredocs.org/clojure.core/concathttp://clojuredocs.org/clojure.core/conjhttp://clojuredocs.org/clojure.core/keep-indexedhttp://clojuredocs.org/clojure.core/keephttp://clojuredocs.org/clojure.core/drop-whilehttp://clojuredocs.org/clojure.core/drop-lasthttp://clojuredocs.org/clojure.core/drophttp://clojuredocs.org/clojure.core/take-whilehttp://clojuredocs.org/clojure.core/take-nthhttp://clojuredocs.org/clojure.core/take-lasthttp://clojuredocs.org/clojure.core/takehttp://clojuredocs.org/clojure.core/butlasthttp://clojuredocs.org/clojure.core/rand-nthhttp://clojuredocs.org/clojure.core/nthnexthttp://clojuredocs.org/clojure.core/nthhttp://clojuredocs.org/clojure.core/nnexthttp://clojuredocs.org/clojure.core/fnexthttp://clojuredocs.org/clojure.core/nfirsthttp://clojuredocs.org/clojure.core/ffirst
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    20/28

    Sequences > Use (Iteration)

    Collections

    Transients > Create

    Transients > Use (General)

    partition-by

    Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of parti

    split-at

    Returns a vector of [(take n coll) (drop n coll)]

    split-with

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

    filter

    Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-e

    remove

    Returns a lazy sequence of the items in coll for which (pred item) returns false. pred must be free of side-

    replace

    Given a map of replacement pairs and a vector/collection, returns a vector/seq with any elements = a key in

    shuffle

    Return a random permutation of coll

    Use (Iteration)

    for

    List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero

    doseq

    Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by "for". Do

    map

    Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, follo

    map-indexed

    Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by

    mapcat

    Returns the result of applying concat to the result of applying map to f and colls. Thus function f should

    reduce

    f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first

    reductions

    Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with i

    max-key

    Returns the x for which (k x), a number, is greatest.

    min-key

    Returns the x for which (k x), a number, is least.

    doall

    When lazy sequences are produced via functions that have side effects, any effects other than those needed t

    dorun

    When lazy sequences are produced via functions that have side effects, any effects other than those needed t

    Transients

    Create

    transient

    Returns a new, transient version of the collection, in constant time.

    persistent!

    Returns a new, persistent version of the transient collection, in constant time. The transient collection ca

    Use (General)

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 20 / 28

    http://clojuredocs.org/clojure.core/persistent!http://clojuredocs.org/clojure.core/transienthttp://clojuredocs.org/clojure.core/dorunhttp://clojuredocs.org/clojure.core/doallhttp://clojuredocs.org/clojure.core/min-keyhttp://clojuredocs.org/clojure.core/max-keyhttp://clojuredocs.org/clojure.core/reductionshttp://clojuredocs.org/clojure.core/reducehttp://clojuredocs.org/clojure.core/mapcathttp://clojuredocs.org/clojure.core/map-indexedhttp://clojuredocs.org/clojure.core/maphttp://clojuredocs.org/clojure.core/doseqhttp://clojuredocs.org/clojure.core/forhttp://clojuredocs.org/clojure.core/shufflehttp://clojuredocs.org/clojure.core/replacehttp://clojuredocs.org/clojure.core/removehttp://clojuredocs.org/clojure.core/filterhttp://clojuredocs.org/clojure.core/split-withhttp://clojuredocs.org/clojure.core/split-athttp://clojuredocs.org/clojure.core/partition-by
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    21/28

    Transients > Use ('Modification')

    Transients > Use (Iteration)

    conj!

    Adds x to the transient collection, and return coll. The 'addition' may happen at different 'places' dependi

    pop!

    Removes the last item from a transient vector. If the collection is empty, throws an exception. Returns coll

    assoc!

    When applied to a transient map, adds mapping of key(s) to val(s). When applied to a transient vector, sets

    dissoc!

    Returns a transient map that doesn't contain a mapping for key(s).

    disj!

    disj[oin]. Returns a transient set of the same (hashed/sorted) type, that does not contain key(s).

    Use ('Modification')

    conj

    conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' m

    concat

    Returns a lazy seq representing the concatenation of the elements in the supplied colls.

    distinct

    Returns a lazy sequence of the elements of coll with duplicates removed

    group-by

    Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will b

    partition

    Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults t

    partition-all

    Returns a lazy sequence of lists like partition, but may include partitions with fewer than n items at the e

    partition-by

    Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of parti

    split-at

    Returns a vector of [(take n coll) (drop n coll)]

    split-with

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

    filter

    Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-e

    remove

    Returns a lazy sequence of the items in coll for which (pred item) returns false. pred must be free of side-

    replace

    Given a map of replacement pairs and a vector/collection, returns a vector/seq with any elements = a key in

    shuffle

    Return a random permutation of coll

    Use (Iteration)

    for

    List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero

    doseq

    Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by "for". Do

    map

    Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, follo

    map-indexed

    Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 21 / 28

    http://clojuredocs.org/clojure.core/map-indexedhttp://clojuredocs.org/clojure.core/maphttp://clojuredocs.org/clojure.core/doseqhttp://clojuredocs.org/clojure.core/forhttp://clojuredocs.org/clojure.core/shufflehttp://clojuredocs.org/clojure.core/replacehttp://clojuredocs.org/clojure.core/removehttp://clojuredocs.org/clojure.core/filterhttp://clojuredocs.org/clojure.core/split-withhttp://clojuredocs.org/clojure.core/split-athttp://clojuredocs.org/clojure.core/partition-byhttp://clojuredocs.org/clojure.core/partition-allhttp://clojuredocs.org/clojure.core/partitionhttp://clojuredocs.org/clojure.core/group-byhttp://clojuredocs.org/clojure.core/distincthttp://clojuredocs.org/clojure.core/concathttp://clojuredocs.org/clojure.core/conjhttp://clojuredocs.org/clojure.core/disj!http://clojuredocs.org/clojure.core/dissoc!http://clojuredocs.org/clojure.core/assoc!http://clojuredocs.org/clojure.core/pop!http://clojuredocs.org/clojure.core/conj!
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    22/28

    Code Structure

    Variables > Create

    Variables > Use

    Variables > Inspect

    mapcat

    Returns the result of applying concat to the result of applying map to f and colls. Thus function f should

    reduce

    f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first

    reductions

    Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with i

    max-key

    Returns the x for which (k x), a number, is greatest.

    min-key

    Returns the x for which (k x), a number, is least.

    doall

    When lazy sequences are produced via functions that have side effects, any effects other than those needed t

    dorun

    When lazy sequences are produced via functions that have side effects, any effects other than those needed t

    Code Structure

    Variables

    Create

    def

    Creates and interns or locates a global var with the name of symbol and a namespace of the value of the curren

    defonce

    defs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated

    intern

    Finds or creates a var named by the symbol name in the namespace ns (which can be a symbol or a namespace),

    declare

    defs the supplied var names with no bindings, useful for making forward declarations.

    Use

    set!

    Assignment special form. When the first operand is a field member access form, the assignment is to the corres

    alter-var-root

    Atomically alters the root binding of var v by applying f to its current value plus any args

    bindingbinding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied i

    with-bindings

    Takes a map of Var/value pairs. Installs for the given Vars the associated values as thread-local bindings.

    with-bindings*

    Takes a map of Var/value pairs. Installs for the given Vars the associated values as thread-local bindings.

    with-local-vars

    varbinding=> symbol init-expr Executes the exprs in a context in which the symbols are bound to vars with

    letfn

    fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+) Takes a vector of function specs and a bod

    gensym

    Returns a new symbol with a unique name. If a prefix string is supplied, the name is prefix# where # is some

    Inspect

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 22 / 28

    http://clojuredocs.org/clojure.core/gensymhttp://clojuredocs.org/clojure.core/letfnhttp://clojuredocs.org/clojure.core/with-local-varshttp://clojuredocs.org/clojure.core/with-bindings*http://clojuredocs.org/clojure.core/with-bindingshttp://clojuredocs.org/clojure.core/bindinghttp://clojuredocs.org/clojure.core/alter-var-roothttp://clojuredocs.org/clojure.core/set!http://clojuredocs.org/clojure.core/declarehttp://clojuredocs.org/clojure.core/internhttp://clojuredocs.org/clojure.core/defoncehttp://clojuredocs.org/clojure.core/defhttp://clojuredocs.org/clojure.core/dorunhttp://clojuredocs.org/clojure.core/doallhttp://clojuredocs.org/clojure.core/min-keyhttp://clojuredocs.org/clojure.core/max-keyhttp://clojuredocs.org/clojure.core/reductionshttp://clojuredocs.org/clojure.core/reducehttp://clojuredocs.org/clojure.core/mapcat
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    23/28

    Code Structure

    Namespaces > Create & Delete

    Namespaces > Inspect

    var

    The symbol must resolve to a var, and the Var object itself (not its value) is returned. The reader macro #'x

    find-var

    Returns the global var named by the namespace-qualified symbol, or nil if no var with that name.

    var-get

    Gets the value in the var object

    var?

    Returns true if v is of type clojure.lang.Var

    bound?

    Returns true if all of the vars provided as arguments have any bound value, root or thread-local. Implies t

    resolve

    same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)

    ns-resolve

    Returns the var or Class to which a symbol will be resolved in the namespace (unless found in the environmen

    special-symbol?

    Returns true if s names a special form

    Namespaces

    Create & Delete

    ns

    Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or mo

    create-ns

    Create a new namespace named by the symbol if one doesn't already exist, returns it or the already-existing

    remove-ns

    Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace.

    Inspect

    *ns*

    A clojure.lang.Namespace object representing the current namespace.

    ns-name

    Returns the name of the namespace, a symbol.

    all-ns

    Returns a sequence of all namespaces.

    the-nsIf passed a namespace, returns it. Else, when passed a symbol, returns the namespace named by it, throwing a

    find-ns

    Returns the namespace named by the symbol or nil if it doesn't exist.

    ns-publics

    Returns a map of the public intern mappings for the namespace.

    ns-interns

    Returns a map of the intern mappings for the namespace.

    ns-refers

    Returns a map of the refer mappings for the namespace.

    ns-aliases

    Returns a map of the aliases for the namespace.

    ns-imports

    Returns a map of the import mappings for the namespace.

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 23 / 28

    http://clojuredocs.org/clojure.core/ns-importshttp://clojuredocs.org/clojure.core/ns-aliaseshttp://clojuredocs.org/clojure.core/ns-refershttp://clojuredocs.org/clojure.core/ns-internshttp://clojuredocs.org/clojure.core/ns-publicshttp://clojuredocs.org/clojure.core/find-nshttp://clojuredocs.org/clojure.core/the-nshttp://clojuredocs.org/clojure.core/all-nshttp://clojuredocs.org/clojure.core/ns-namehttp://clojuredocs.org/clojure.core/*ns*http://clojuredocs.org/clojure.core/remove-nshttp://clojuredocs.org/clojure.core/create-nshttp://clojuredocs.org/clojure.core/nshttp://clojuredocs.org/clojure.core/special-symbol_qhttp://clojuredocs.org/clojure.core/ns-resolvehttp://clojuredocs.org/clojure.core/resolvehttp://clojuredocs.org/clojure.core/bound_qhttp://clojuredocs.org/clojure.core/var_qhttp://clojuredocs.org/clojure.core/var-gethttp://clojuredocs.org/clojure.core/find-varhttp://clojuredocs.org/clojure.core/var
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    24/28

    Namespaces > Use

    Namespaces > Misc

    Code Structure

    Hierarchies > General

    Code Structure

    User Defined Types > General

    ns-map

    Returns a map of all the mappings for the namespace.

    Use

    in-ns

    Sets *ns* to the namespace named by the symbol, creating it if needed.

    ns-resolve

    Returns the var or Class to which a symbol will be resolved in the namespace (unless found in the environmen

    ns-unalias

    Removes the alias for the symbol from the namespace.

    ns-unmap

    Removes the mappings for the symbol from the namespace.

    alias

    Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used,

    Misc

    namespace-mungeConvert a Clojure namespace name to a legal Java package name.

    Hierarchies

    General

    make-hierarchy

    Creates a hierarchy object for use with derive, isa? etc.

    derive

    Establishes a parent/child relationship between parent and tag. Parent must be a namespace-qualified symbol

    underive

    Removes a parent/child relationship between parent and tag. h must be a hierarchy obtained from make-hierarc

    parents

    Returns the immediate parents of tag, either via a Java type inheritance relationship or a relationship esta

    ancestors

    Returns the immediate and indirect parents of tag, either via a Java type inheritance relationship or a rela

    descendants

    Returns the immediate and indirect children of tag, through a relationship established via derive. h must be

    isa?Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java

    User Defined Types

    General

    defprotocol

    A protocol is a named set of named methods and their signatures: (defprotocol AProtocolName ;optional d

    defrecord

    (defrecord name [fields*] options* specs*) Currently there are no options. Each spec consists of a pr

    deftype

    (deftype name [fields*] options* specs*) Currently there are no options. Each spec consists of a prot

    reify

    reify is a macro with the following structure: (reify options* specs*) Currently there are no options.

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 24 / 28

    http://clojuredocs.org/clojure.core/reifyhttp://clojuredocs.org/clojure.core/deftypehttp://clojuredocs.org/clojure.core/defrecordhttp://clojuredocs.org/clojure.core/defprotocolhttp://clojuredocs.org/clojure.core/isa_qhttp://clojuredocs.org/clojure.core/descendantshttp://clojuredocs.org/clojure.core/ancestorshttp://clojuredocs.org/clojure.core/parentshttp://clojuredocs.org/clojure.core/underivehttp://clojuredocs.org/clojure.core/derivehttp://clojuredocs.org/clojure.core/make-hierarchyhttp://clojuredocs.org/clojure.core/namespace-mungehttp://clojuredocs.org/clojure.core/aliashttp://clojuredocs.org/clojure.core/ns-unmaphttp://clojuredocs.org/clojure.core/ns-unaliashttp://clojuredocs.org/clojure.core/ns-resolvehttp://clojuredocs.org/clojure.core/in-nshttp://clojuredocs.org/clojure.core/ns-map
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    25/28

    Code Structure

    Metadata > General

    Environment

    Require / Import > General

    Environment

    Code > General

    extend

    Implementations of protocol methods can be provided using the extend construct: (extend AType AProtocol

    extend-protocol

    Useful when you want to provide several implementations of the same protocol all at once. Takes a single pro

    extend-type

    A macro that expands into an extend call. Useful when you are supplying the definitions explicitly inline, e

    extenders

    Returns a collection of the types explicitly extending protocol

    Metadata

    General

    meta

    Returns the metadata of obj, returns nil if there is no metadata.

    with-meta

    Returns an object of the same type and value as obj, with map m as its metadata.

    vary-meta

    Returns an object of the same type and value as obj, with (apply f (meta obj) args) as its metadata.

    reset-meta!

    Atomically resets the metadata for a namespace/var/ref/agent/atom

    alter-meta!

    Atomically sets the metadata for a namespace/var/ref/agent/atom to be: (apply f its-current-meta args) f

    Environment

    Require / Import

    General

    use

    Like 'require, but also refers to each lib's namespace using clojure.core/refer. Use :use in the ns macro in

    require

    Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a

    import

    import-list => (package-symbol class-name-symbols*) For each name in class-name-symbols, adds a mapping fro

    refer-clojure

    Same as (refer 'clojure.core )

    refer

    refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude li

    Code

    General

    *compile-files*

    Set to true when compiling files, false otherwise.

    *compile-path*

    Specifies the directory where 'compile' will write out .class files. This directory must be in the classpath

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 25 / 28

    http://clojuredocs.org/clojure.core/*compile-path*http://clojuredocs.org/clojure.core/*compile-files*http://clojuredocs.org/clojure.core/referhttp://clojuredocs.org/clojure.core/refer-clojurehttp://clojuredocs.org/clojure.core/importhttp://clojuredocs.org/clojure.core/requirehttp://clojuredocs.org/clojure.core/usehttp://clojuredocs.org/clojure.core/alter-meta!http://clojuredocs.org/clojure.core/reset-meta!http://clojuredocs.org/clojure.core/vary-metahttp://clojuredocs.org/clojure.core/with-metahttp://clojuredocs.org/clojure.core/metahttp://clojuredocs.org/clojure.core/extendershttp://clojuredocs.org/clojure.core/extend-typehttp://clojuredocs.org/clojure.core/extend-protocolhttp://clojuredocs.org/clojure.core/extend
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    26/28

    Environment

    IO > General

    *file*

    The path of the file being evaluated, as a String. When there is no file, e.g. in the REPL, the value is no

    *warn-on-reflection*

    When set to true, the compiler will emit warnings when reflection is needed to resolve Java method calls or

    compile

    Compiles the namespace named by the symbol lib into a set of classfiles. The source for the lib must be in a

    load

    Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins wit

    load-file

    Sequentially read and evaluate the set of forms contained in the file.

    load-reader

    Sequentially read and evaluate the set of forms contained in the stream/file

    load-string

    Sequentially read and evaluate the set of forms contained in the string

    read

    Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. str

    read-stringReads one object from the string s. Note that read-string can execute code (controlled by *read-eval*), a

    gen-class

    When compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as al

    gen-interface

    When compiling, generates compiled bytecode for an interface with the given package-qualified :name (which,

    loaded-libs

    Returns a sorted set of symbols naming the currently loaded libs

    test

    test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception

    IO

    General

    *in*

    A java.io.Reader object representing standard input for read operations. Defaults to System/in, wrapped in

    *out*

    A java.io.Writer object representing standard output for print operations. Defaults to System/out, wrapped

    *err*

    A java.io.Writer object representing standard error for print operations. Defaults to System/err, wrapped i

    print

    Prints the object(s) to the output stream that is the current value of *out*. print and println produce out

    printf

    Prints formatted output, as per format

    println

    Same as print followed by (newline)

    pr

    Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separat

    prn

    Same as pr followed by (newline). Observes *flush-on-newline*

    print-str

    print to a string, returning it

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 26 / 28

    http://clojuredocs.org/clojure.core/print-strhttp://clojuredocs.org/clojure.core/prnhttp://clojuredocs.org/clojure.core/prhttp://clojuredocs.org/clojure.core/printlnhttp://clojuredocs.org/clojure.core/printfhttp://clojuredocs.org/clojure.core/printhttp://clojuredocs.org/clojure.core/*err*http://clojuredocs.org/clojure.core/*out*http://clojuredocs.org/clojure.core/*in*http://clojuredocs.org/clojure.core/testhttp://clojuredocs.org/clojure.core/loaded-libshttp://clojuredocs.org/clojure.core/gen-interfacehttp://clojuredocs.org/clojure.core/gen-classhttp://clojuredocs.org/clojure.core/read-stringhttp://clojuredocs.org/clojure.core/readhttp://clojuredocs.org/clojure.core/load-stringhttp://clojuredocs.org/clojure.core/load-readerhttp://clojuredocs.org/clojure.core/load-filehttp://clojuredocs.org/clojure.core/loadhttp://clojuredocs.org/clojure.core/compilehttp://clojuredocs.org/clojure.core/*warn-on-reflection*http://clojuredocs.org/clojure.core/*file*
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    27/28

    Environment

    REPL > General

    Environment

    println-str

    println to a string, returning it

    pr-str

    pr to a string, returning it

    prn-str

    prn to a string, returning it

    newline

    Writes a platform-specific newline to *out*

    flush

    Flushes the output stream that is the current value of *out*

    read-line

    Reads the next line from stream that is the current value of *in* .

    slurp

    Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complet

    spit

    Opposite of slurp. Opens f with writer, writes content, then closes f. Options passed to clojure.java.io/wr

    with-in-str

    Evaluates body in a context in which *in* is bound to a fresh StringReader initialized with the string s.

    with-out-str

    Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by

    with-open

    bindings => [name init ...] Evaluates body in a try expression with names bound to the values of the init

    REPL

    General

    *1

    bound in a repl thread to the most recent value printed

    *2

    bound in a repl thread to the second most recent value printed

    *3

    bound in a repl thread to the third most recent value printed

    *e

    bound in a repl thread to the most recent exception caught by the repl

    *print-dup*

    When set to logical true, objects will be printed in a way that preserves their type when read in later.

    *print-length*

    *print-length* controls how many items of each collection the printer will print. If it is bound to logical

    *print-level*

    *print-level* controls how many levels deep the printer will print nested objects. If it is bound to logical

    *print-meta*

    If set to logical true, when printing an object, its metadata will also be printed in a form that can be rea

    *print-readably*

    When set to logical false, strings and characters will be printed with non-alphanumeric characters converted

    Misc

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    http://clojuredocs.org/quickref 27 / 28

    http://clojuredocs.org/clojure.core/*print-readably*http://clojuredocs.org/clojure.core/*print-meta*http://clojuredocs.org/clojure.core/*print-level*http://clojuredocs.org/clojure.core/*print-length*http://clojuredocs.org/clojure.core/*print-dup*http://clojuredocs.org/clojure.core/*ehttp://clojuredocs.org/clojure.core/*3http://clojuredocs.org/clojure.core/*2http://clojuredocs.org/clojure.core/*1http://clojuredocs.org/clojure.core/with-openhttp://clojuredocs.org/clojure.core/with-out-strhttp://clojuredocs.org/clojure.core/with-in-strhttp://clojuredocs.org/clojure.core/spithttp://clojuredocs.org/clojure.core/slurphttp://clojuredocs.org/clojure.core/read-linehttp://clojuredocs.org/clojure.core/flushhttp://clojuredocs.org/clojure.core/newlinehttp://clojuredocs.org/clojure.core/prn-strhttp://clojuredocs.org/clojure.core/pr-strhttp://clojuredocs.org/clojure.core/println-str
  • 8/10/2019 Clojure Quick Reference ClojureDocs - Community-Powered Cl

    28/28

    Misc > GeneralGeneral

    *clojure-version*

    The version info for Clojure core, as a map containing :major :minor :incremental and :qualifier keys. Feat

    clojure-version

    Returns clojure version as a printable string.

    *command-line-args*

    A sequence of the supplied command line arguments, or nil if none were supplied

    time

    Evaluates expr and prints the time it took. Returns the value of expr.

    - -

    Brought to you by @heyzk.

    StarStar 160160 Tweet

    Clojure Quick Reference | ClojureDocs - Community-Powered Clojure Documentation and Examples 2015-01-13

    https://twitter.com/sharehttps://twitter.com/heyzkhttp://clojuredocs.org/clojure.core/timehttp://clojuredocs.org/clojure.core/*command-line-args*http://clojuredocs.org/clojure.core/clojure-versionhttp://clojuredocs.org/clojure.core/*clojure-version*