Skip to main content

Control Flow

  • case

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

  • cond

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

  • condp

    Takes a binary predicate, an expression, and a set of clauses. Each clause can take the form of either: test-expr r...

  • if

    Evaluates test, then consequent or alternative.

  • if-let

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

  • when

    Evaluates test. If logical true, 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 test

  • when-not

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

  • Throwable->map

    Constructs a data representation for a Throwable with keys: :cause - root cause message :phase - error phase ...

  • catch

    Catch clause inside try.

  • ex-cause

    Returns the cause of ex if ex is a Throwable. Otherwise returns nil.

  • ex-data

    Returns exception data (a map) if ex is an IExceptionInfo. Otherwise returns nil.

  • ex-info

    Create an instance of ExceptionInfo, a RuntimeException subclass that carries a map of additional data.

  • ex-message

    Returns the message attached to ex if ex is a Throwable. Otherwise returns nil.

  • finally

    Finally clause inside try, runs on exit.

  • throw

    Throws an instance of Throwable.

  • try

    try / catch / finally exception handling.

  • assert

    Evaluates expression x and throws an AssertionError with optional message if x does not evaluate to logical true. A...

  • comment

    Ignores body, yields nil

  • delay

    Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with...

  • 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-transaction-va...

  • do

    Evaluates expressions in order, returning the last.

  • dotimes

    bindings => name n Repeatedly executes body (presumably for side-effects) with name bound to integers from 0 throug...

  • doto

    Evaluates x then calls all of the methods and functions with the value of x supplied at the front of the given argumen...

  • ensure-reduced

    If x is already reduced?, returns it, else returns (reduced x)

  • eval

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

  • force

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

  • halt-when

    Returns a transducer that ends transduction when pred returns true for an input. When retf is supplied it must be a fn...

  • if-not

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

  • if-some

    bindings => binding-form test If test is not nil, evaluates then with binding-form bound to the value of test, if...

  • io!

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

  • lazy-cat

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

  • letfn

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

  • reduced

    Wraps x in a way such that a reduce will terminate with the value x

  • reduced?

    Returns true if x is the result of a call to reduced

  • time

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

  • unreduced

    If x is reduced?, returns (deref x), else returns x

  • when-first

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

  • when-some

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

  • with-in-str

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

  • with-precision

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

  • with-redefs

    binding => var-symbol temp-value-expr Temporarily redefines Vars while executing the body. The temp-value-exprs wi...

  • with-redefs-fn

    Temporarily redefines Vars during a call to func. Each val of binding-map will replace the root value of its key whic...

  • doseq

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

  • for

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

  • loop

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

  • recur

    Rebinds and transfers control to the recursion point.

  • trampoline

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

  • while

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