1.10.0-alpha6 docs






    Index of all namespaces

    « Project + dependencies

    Core language

    Fundamental library of the Clojure language


    - * *' *1 *2 *3 + +' - -' -> ->> .. / < <= = == > >0? >1? >=

    A *agent* *allow-unresolved-vars* *assert* ->ArrayChunk accessor aclone add-annotation add-annotations add-classpath add-doc-and-meta add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! alter-var-root amap ams ams-check ancestors and any? apply areduce array array-map as-> aset aset-boolean aset-byte aset-char aset-double aset-float aset-int aset-long aset-short asm-type assert assert-args assert-same-protocol assert-valid-fdecl assoc assoc! assoc-in associative? atom await await-for await1

    B bases bean bigdec bigint biginteger binding binding-conveyor-fn bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array boolean? booleans bound-fn bound-fn* bound? bounded-count build-positional-factory butlast byte byte-array bytes bytes?

    C *clojure-version* *command-line-args* *compile-files* *compile-path* *compiler-options* -cache-protocol-fn case case-map cast cat char char-array char-escape-string char-name-string char? chars check-cyclic-dependency check-valid-options chunk chunk-append chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement completing concat cond cond-> cond->> condp conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct ctor-sigs cycle

    D *data-readers* *default-data-reader-fn* data-reader-urls data-reader-var dec dec' decimal? declare dedupe def-aset default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol defrecord defstruct deftype delay delay? deliver denominator deref deref-as-map deref-future derive descendants descriptor destructure disj disj! dissoc dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array double? doubles drop drop-last drop-while

    E *e *err* ->Eduction eduction emit-defrecord emit-deftype* emit-extend-protocol emit-extend-type emit-hinted-impl emit-impl emit-method-builder emit-protocol empty EMPTY-NODE empty? ensure ensure-reduced enumeration-seq error-handler error-mode escape-class-name eval even? every-pred every? ex-data ex-info expand-method-impl-cache extend extend-protocol extend-type extenders extends?

    F *file* *flush-on-newline* *fn-loader* false? ffirst file-seq filter filter-key filter-methods filterv find find-field find-keyword find-ns find-protocol-impl find-protocol-method find-var first fits-table? flatten float float-array float? floats flush fn fn? fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future?

    G gen-class gen-interface generate-class generate-interface generate-proxy gensym get get-in get-method get-proxy-class get-super-and-interfaces get-thread-bindings get-validator global-hierarchy group-by group-by-sig

    H halt-when hash hash-combine hash-map hash-ordered-coll hash-set hash-unordered-coll

    I *in* ident? identical? identity if-let if-not if-some ifn? imap-cons implements? import in-ns inc inc' indexed? init-proxy Inst inst-ms inst? instance? int int-array int? integer? interleave intern interpose into into-array into1 ints io! is-annotation? is-runtime-annotation? isa? iterate iterator-seq

    J juxt

    K keep keep-indexed key keys keyword keyword?

    L *loaded-libs* *loading-verbosely* last lazy-cat lazy-seq let letfn libspec? lift-ns line-seq list list* list? load load-all load-data-reader-file load-data-readers load-file load-lib load-libs load-one load-reader load-string loaded-libs locking long long-array longs loop

    M *math-context* macroexpand macroexpand-1 make-array make-hierarchy map map-entry? map-indexed map? mapcat mapv max max-key max-mask-bits max-switch-table-size maybe-destructured maybe-min-hash memfn memoize merge merge-hash-collisions merge-with meta method-sig methods min min-key mix-collection-hash mk-am mk-bound-fn mod most-specific munge

    N *ns* name namespace namespace-munge nary-inline nat-int? neg-int? neg? newline next nfirst nil? nnext non-private-methods normalize-slurp-opts not not-any? not-empty not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias ns-unmap nth nthnext nthrest num number? numerator

    O *out* object-array odd? or overload-name

    P *pending-paths* *print-dup* *print-length* *print-level* *print-meta* *print-namespace-maps* *print-readably* parents parse-impls parse-opts parse-opts+specs partial partition partition-all partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos-int? pos? pr pr-on pr-str pref prefer-method prefers prep-hashes prep-ints prependss preserving-reduced prim->class primitives-classnames print print-ctor print-dup print-initialized print-map print-meta print-method print-object print-prefix-map print-sequential print-simple print-str print-tagged-object print-throwable printf println println-str prn prn-str process-annotation promise protected-final-methods protocol? proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues

    Q qualified-ident? qualified-keyword? qualified-symbol? quot

    R *read-eval* *reader-resolver* -reset-methods rand rand-int rand-nth random-sample range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern re-seq read read-line read-string reader-conditional reader-conditional? realized? record? reduce reduce-kv reduce1 reduced reduced? reductions ref ref-history-count ref-max-history ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! reset-vals! resolve rest restart-agent resultset-seq reverse reversible? root-directory root-resource rseq rsubseq run!

    S *source-path* *suppress-read* satisfies? second select-keys send send-off send-via seq seq? seqable? seque sequence sequential? set set-agent-send-executor! set-agent-send-off-executor! set-error-handler! set-error-mode! set-validator! set? setup-reference shift-mask short short-array shorts shuffle shutdown-agents sigs simple-ident? simple-keyword? simple-symbol? slurp some some-> some->> some-fn some? sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? special-symbol? spit split-at split-with spread StackTraceElement->vec str string? strip-ns struct struct-map subs subseq subvec super-chain supers swap! swap-vals! symbol symbol? sync system-newline

    T tagged-literal tagged-literal? take take-last take-nth take-while test the-class the-ns thread-bound? throw-if Throwable->map time to-array to-array-2d trampoline transduce transient tree-seq true? type

    U *unchecked-math* *use-context-classloader* unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote unquote-splicing unreduced unsigned-bit-shift-right update update-in update-proxy uri? use uuid?

    V *verbose-defrecords* ->Vec ->VecNode ->VecSeq val valid-java-method-name validate-fields validate-generate-class-options vals var-get var-set var? vary-meta vec vector vector-of vector? volatile! volatile? vreset! vswap!

    W *warn-on-reflection* when when-class when-first when-let when-not when-some while with-bindings with-bindings* with-in-str with-loading-context with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn

    X xml-seq

    Z zero? zipmap

    A library for reduction and parallel folding. Alpha and subject
    to change.  Note that fold and its derivatives require Java 7+ or
    Java 6 + jsr166y.jar for fork/join support. See Clojure's pom.xml for the
    dependency info.
    Helper namespace for
    Prevents console apps from becoming GUI unnecessarily.
    A Pretty Printer for Clojure
    clojure.pprint implements a flexible system for printing structured data
    in a pleasing, easy-to-understand format. Basic use of the pretty printer is 
    simple, just call pprint instead of println. More advanced users can use 
    the building blocks provided to create custom output formats. 
    Out of the box, pprint supports a simple structured format for basic data 
    and a specialized format for Clojure source code. More advanced formats, 
    including formats that don't look like Clojure data at all like XML and 
    JSON, can be rendered by creating custom dispatch functions. 
    In addition to the pprint function, this module contains cl-format, a text 
    formatting function which is fully compatible with the format function in 
    Common Lisp. Because pretty printing directives are directly integrated with
    cl-format, it supports very concise custom dispatch. It also provides
    a more powerful alternative to Clojure's standard format function.
    See documentation for pprint and cl-format for more information or 
    complete documentation on the Clojure web site on GitHub.


    A abort? absolute-reposition absolute-tabulation add-core-ns add-english-scales add-to-buffer ancestor? arg-navigator

    B base-str binding-map boolean-conditional brackets buffer-blob buffer-blob? buffer-length

    C *code-table* *current-length* *current-level* c-write-char cached-compile capitalize-string capitalize-word-writer check-arg-conditional check-enumerated-arg check-flags choice-conditional cl-format code-dispatch collect-clauses column-writer compile-directive compile-format compile-raw-string compiled-directive conditional-newline consume consume-while convert-ratio

    D *default-page-width* defdirectives deftype directive-table dollar-float downcase-writer

    E else-separator? emit-nl emit-nl? end-block end-block-t end-block-t? english-cardinal-tens english-cardinal-units english-ordinal-tens english-ordinal-units english-scale-numbers execute-format execute-sub-format expand-fixed exponential-float extract-flags extract-param extract-params

    F *format-str* fixed-float flag-defs float-parts float-parts-base format-ascii format-cardinal-english format-error format-integer format-logical-block format-new-roman format-old-roman format-ordinal-english format-roman format-simple-cardinal format-simple-number format-simple-ordinal formatter formatter-out fresh-line

    G general-float get-column get-field get-fixed get-format-arg get-line get-max-column get-miser-width get-pretty-writer get-section get-sub-section get-writer getf group-by*

    I inc-s indent indent-t indent-t? init-cap-writer init-navigator insert-decimal insert-scaled-decimal integral? iterate-list-of-sublists iterate-main-list iterate-main-sublists iterate-sublist

    J java-base-formats justify-clauses

    L level-exceeded linear-nl? logical-block logical-block-or-justify ltrim

    M make-buffer-blob make-end-block-t make-indent-t make-nl-t make-pretty-writer make-start-block-t map-params map-passing-context map-ref-type miser-nl? modify-case multi-defn

    N needs-pretty new-roman-table next-arg next-arg-or-nil nl nl-t nl-t?

    O old-roman-table opt-base-str orig-pr

    P *print-base* *print-circle* *print-lines* *print-miser-width* *print-pprint-dispatch* *print-pretty* *print-radix* *print-right-margin* *print-shared* *print-suppress-namespaces* p-write-char param-pattern parse-lb-options plain-character pll-mod-body pp pp-newline pprint pprint-anon-func pprint-array pprint-binding-form pprint-code-list pprint-code-symbol pprint-cond pprint-condp pprint-defn pprint-hold-first pprint-ideref pprint-if pprint-indent pprint-let pprint-list pprint-logical-block pprint-map pprint-newline pprint-ns pprint-ns-reference pprint-pqueue pprint-reader-macro pprint-set pprint-simple-code-list pprint-simple-default pprint-simple-list pprint-tab pprint-vector pr-with-base prefix-count prerr pretty-character pretty-writer pretty-writer? print-length-loop print-table prlabel process-bracket process-clause process-directive-table-element process-nesting

    R readable-character reader-macros realize-parameter realize-parameter-list relative-reposition relative-tabulation remainders render-clauses right-bracket round-str rtrim

    S *symbol-map* section separator? set-field set-indent set-logical-block-callback set-max-column set-miser-width set-pprint-dispatch setf simple-dispatch single-defn special-chars special-params special-radix-markers split-at-newline start-block start-block-t start-block-t?

    T table-ize tok tokens-fit? toks translate-param tuple-map two-forms type-map

    U unzip-map upcase-writer update-nl-state use-method

    W with-pprint-dispatch with-pretty-writer write write-buffered-output write-initial-lines write-line write-option-table write-out write-to-base write-token write-token-string write-tokens write-white-space

    Reflection on Host Types
    Alpha - subject to change.
    Two main entry points: 
    * type-reflect reflects on something that implements TypeReference.
    * reflect (for REPL use) reflects on the class of an instance, or
      on a class if passed a class
    Key features:
    * Exposes the read side of reflection as pure data. Reflecting
      on a type returns a map with keys :bases, :flags, and :members.
    * Canonicalizes class names as Clojure symbols. Types can extend
      to the TypeReference protocol to indicate that they can be
      unambiguously resolved as a type name. The canonical format
      requires one non-Java-ish convention: array brackets are <>
      instead of [] so they can be part of a Clojure symbol.
    * Pluggable Reflectors for different implementations. The default
      JavaReflector is good when you have a class in hand, or use
      the AsmReflector for "hands off" reflection without forcing
      classes to load.
    Platform implementers must:
    * Create an implementation of Reflector.
    * Create one or more implementations of TypeReference.
    * def default-reflector to be an instance that satisfies Reflector.
    Clojure String utilities
    It is poor form to (:use clojure.string). Instead, use require
    with :as to specify a prefix, e.g.
      (:require [clojure.string :as str]))
    Design notes for clojure.string:
    1. Strings are objects (as opposed to sequences). As such, the
       string being manipulated is the first argument to a function;
       passing nil will result in a NullPointerException unless
       documented otherwise. If you want sequence-y behavior instead,
       use a sequence.
    2. Functions are generally not lazy, and call straight to host
       methods where those are available and efficient.
    3. Functions take advantage of String implementation details to
       write high-performing loop/recurs instead of using higher-order
       functions. (This is not idiomatic in general-purpose application
    4. When a function is documented to accept a string argument, it
       will take any implementation of the correct *interface* on the
       host platform. In Java, this is CharSequence, which is more
       general than String. In ordinary usage you will almost always
       pass concrete strings. If you are doing something unusual,
       e.g. passing a mutable implementation of CharSequence, then
       thread-safety is your responsibility.
    Macros that expand to repeated copies of a template expression.
    A unit testing framework.
    The core of the library is the "is" macro, which lets you make
    assertions of any arbitrary expression:
    (is (= 4 (+ 2 2)))
    (is (instance? Integer 256))
    (is (.startsWith "abcde" "ab"))
    You can type an "is" expression directly at the REPL, which will
    print a message if it fails.
        user> (is (= 5 (+ 2 2)))
        FAIL in  (:1)
        expected: (= 5 (+ 2 2))
          actual: (not (= 5 4))
    The "expected:" line shows you the original expression, and the
    "actual:" shows you what actually happened.  In this case, it
    shows that (+ 2 2) returned 4, which is not = to 5.  Finally, the
    "false" on the last line is the value returned from the
    expression.  The "is" macro always returns the result of the
    inner expression.
    There are two special assertions for testing exceptions.  The
    "(is (thrown? c ...))" form tests if an exception of class c is
    (is (thrown? ArithmeticException (/ 1 0))) 
    "(is (thrown-with-msg? c re ...))" does the same thing and also
    tests that the message on the exception matches the regular
    expression re:
    (is (thrown-with-msg? ArithmeticException #"Divide by zero"
                          (/ 1 0)))
    "is" takes an optional second argument, a string describing the
    assertion.  This message will be included in the error report.
    (is (= 5 (+ 2 2)) "Crazy arithmetic")
    In addition, you can document groups of assertions with the
    "testing" macro, which takes a string followed by any number of
    assertions.  The string will be included in failure reports.
    Calls to "testing" may be nested, and all of the strings will be
    joined together with spaces in the final report, in a style
    similar to RSpec <>
    (testing "Arithmetic"
      (testing "with positive integers"
        (is (= 4 (+ 2 2)))
        (is (= 7 (+ 3 4))))
      (testing "with negative integers"
        (is (= -4 (+ -2 -2)))
        (is (= -1 (+ 3 -4)))))
    Note that, unlike RSpec, the "testing" macro may only be used
    INSIDE a "deftest" or "with-test" form (see below).
    There are two ways to define tests.  The "with-test" macro takes
    a defn or def form as its first argument, followed by any number
    of assertions.  The tests will be stored as metadata on the
        (defn my-function [x y]
          (+ x y))
      (is (= 4 (my-function 2 2)))
      (is (= 7 (my-function 3 4))))
    As of Clojure SVN rev. 1221, this does not work with defmacro.
    The other way lets you define tests separately from the rest of
    your code, even in a different namespace:
    (deftest addition
      (is (= 4 (+ 2 2)))
      (is (= 7 (+ 3 4))))
    (deftest subtraction
      (is (= 1 (- 4 3)))
      (is (= 3 (- 7 4))))
    This creates functions named "addition" and "subtraction", which
    can be called like any other function.  Therefore, tests can be
    grouped and composed, in a style similar to the test framework in
    Peter Seibel's "Practical Common Lisp"
    (deftest arithmetic
    The names of the nested tests will be joined in a list, like
    "(arithmetic addition)", in failure reports.  You can use nested
    tests to set up a context shared by several tests.
    Run tests with the function "(run-tests namespaces...)":
    (run-tests 'your.namespace 'some.other.namespace)
    If you don't specify any namespaces, the current namespace is
    used.  To run all tests in all namespaces, use "(run-all-tests)".
    By default, these functions will search for all tests defined in
    a namespace and run them in an undefined order.  However, if you
    are composing tests, as in the "arithmetic" example above, you
    probably do not want the "addition" and "subtraction" tests run
    separately.  In that case, you must define a special function
    named "test-ns-hook" that runs your tests in the correct order:
    (defn test-ns-hook []
    Note: test-ns-hook prevents execution of fixtures (see below).
    You can bind the variable "*load-tests*" to false when loading or
    compiling code in production.  This will prevent any tests from
    being created by "with-test" or "deftest".
    Fixtures allow you to run code before and after tests, to set up
    the context in which tests should be run.
    A fixture is just a function that calls another function passed as
    an argument.  It looks like this:
    (defn my-fixture [f]
       Perform setup, establish bindings, whatever.
      (f)  Then call the function we were passed.
       Tear-down / clean-up code here.
    Fixtures are attached to namespaces in one of two ways.  "each"
    fixtures are run repeatedly, once for each test function created
    with "deftest" or "with-test".  "each" fixtures are useful for
    establishing a consistent before/after state for each test, like
    clearing out database tables.
    "each" fixtures can be attached to the current namespace like this:
    (use-fixtures :each fixture1 fixture2 ...)
    The fixture1, fixture2 are just functions like the example above.
    They can also be anonymous functions, like this:
    (use-fixtures :each (fn [f] setup... (f) cleanup...))
    The other kind of fixture, a "once" fixture, is only run once,
    around ALL the tests in the namespace.  "once" fixtures are useful
    for tasks that only need to be performed once, like establishing
    database connections, or for time-consuming tasks.
    Attach "once" fixtures to the current namespace like this:
    (use-fixtures :once fixture1 fixture2 ...)
    Note: Fixtures and test-ns-hook are mutually incompatible.  If you
    are using test-ns-hook, fixture functions will *never* be run.
    All the test reporting functions write to the var *test-out*.  By
    default, this is the same as *out*, but you can rebind it to any
    PrintWriter.  For example, it could be a file opened with
    You can extend the behavior of the "is" macro by defining new
    methods for the "assert-expr" multimethod.  These methods are
    called during expansion of the "is" macro, so they should return
    quoted forms to be evaluated.
    You can plug in your own test-reporting framework by rebinding
    the "report" function: (report event)
    The 'event' argument is a map.  It will always have a :type key,
    whose value will be a keyword signaling the type of event being
    reported.  Standard events with :type value of :pass, :fail, and
    :error are called when an assertion passes, fails, and throws an
    exception, respectively.  In that case, the event will also have
    the following keys:
      :expected   The form that was expected to be true
      :actual     A form representing what actually occurred
      :message    The string message given as an argument to 'is'
    The "testing" strings will be a list in "*testing-contexts*", and
    the vars being tested will be a list in "*testing-vars*".
    Your "report" function should wrap any printing calls in the
    "with-test-out" macro, which rebinds *out* to the current value
    of *test-out*.
    For additional event types, see the examples in the code.
    clojure.test extension for JUnit-compatible XML output.
    JUnit ( is the most popular unit-testing library
    for Java.  As such, tool support for JUnit output formats is
    common.  By producing compatible output from tests, this tool
    support can be exploited.
    To use, wrap any calls to clojure.test/run-tests in the
    with-junit-output macro, like this:
      (use 'clojure.test)
      (use 'clojure.test.junit)
        (run-tests '
    To write the output to a file, rebind clojure.test/*test-out* to
    your own PrintWriter (perhaps opened using
    clojure.test extensions for the Test Anything Protocol (TAP)
    TAP is a simple text-based syntax for reporting test results.  TAP
    was originally developed for Perl, and now has implementations in
    several languages.  For more information on TAP, see and
    To use this library, wrap any calls to
    clojure.test/run-tests in the with-tap-output macro,
    like this:
      (use 'clojure.test)
      (use 'clojure.test.tap)
       (run-tests '
    This file defines a generic tree walker for Clojure data
    structures.  It takes any data structure (list, vector, map, set,
    seq), calls a function on every element, and uses the return value
    of the function in place of the original.  This makes it fairly
    easy to write recursive search-and-replace functions, as shown in
    the examples.
    Note: "walk" supports all Clojure data structures EXCEPT maps
    created with sorted-map-by.  There is no (obvious) way to retrieve
    the sorting function.