Clojure Core and Contrib API Overview


This page documents the various projects in the Clojure organization including the core Clojure libraries and the various contributed libraries.

Each project entry has a link to the project's own API documentation page that has complete documentation for that API.

The API index has a complete, alphabetized index of all the functions in the various projects.

These projects are made available under the Eclipse Public License (EPL). They are copyright 2008-2013 by Rich Hickey and the various contributors.

Note: Not all the projects in Clojure are currently documented on these pages. Please see https://github.com/clojure for the full repository of projects under the Clojure umbrella.




algo.generic


Project API Overview

clojure.algo.generic.arithmetic

by Konrad Hinsen
Generic arithmetic interface
This library defines generic versions of + - * / as multimethods
that can be defined for any type. The minimal required 
implementations for a type are binary + and * plus unary - and /.
Everything else is derived from these automatically. Explicit
binary definitions for - and / can be provided for
efficiency reasons.

clojure.algo.generic.collection

by Konrad Hinsen
Generic collection interface
This library defines generic versions of common
collection-related functions as multimethods that can be
defined for any type.

clojure.algo.generic.comparison

by Konrad Hinsen
Generic comparison interface
This library defines generic versions of = not= < > <= >= zero?
as multimethods that can be defined for any type. Of the
greater/less-than relations, types must minimally implement >.

clojure.algo.generic.functor

by Konrad Hinsen
Generic functor interface (fmap)

clojure.algo.generic.math-functions

by Konrad Hinsen
Generic math function interface
This library defines generic versions of common mathematical
functions such as sqrt or sin as multimethods that can be
defined for any type.


algo.graph


Project API Overview

clojure.algo.graph

by Jeffrey Straszheim
Basic graph theory algorithms


algo.monads


Project API Overview

clojure.algo.monads

by Konrad Hinsen
This library contains the most commonly used monads as well
as macros for defining and using monads and useful monadic
functions.


clojure


Project API Overview

clojure.core

Fundamental library of the Clojure language

clojure.data

by Stuart Halloway
Non-core data functions.

clojure.edn

by Rich Hickey
edn reading.

clojure.inspector

by Rich Hickey
Graphical object inspector for Clojure data structures.

clojure.instant


    
    
  

clojure.java.browse

by Christophe Grand
Start a web browser from Clojure

clojure.java.io


    
    
  

clojure.java.javadoc

by Christophe Grand, Stuart Sierra
A repl helper to quickly open javadocs.

clojure.java.shell


    
    
  

clojure.main


    
    
  

clojure.pprint

by Tom Faulhaber
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 the clojure web site on github.

clojure.reflect

by Stuart Halloway
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.repl

by Chris Houser, Christophe Grand, Stephen Gilardi, Michel Salim
Utilities meant to be used interactively at the REPL

clojure.set


    
    
  

clojure.stacktrace

by Stuart Sierra
Print stack traces oriented towards Clojure, not Java.

clojure.string


    
    
  

clojure.template

by Stuart Sierra
Macros that expand to repeated copies of a template expression.

clojure.test

by Stuart Sierra, with contributions and suggestions by Chas Emerick, Allen Rohner, and Stuart Halloway
A unit testing framework.

ASSERTIONS

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))
    false

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
thrown:

(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)))

DOCUMENTING TESTS

"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 <http://rspec.info/>

(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).


DEFINING TESTS

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
definition.

(with-test
    (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.
See http://code.google.com/p/clojure/issues/detail?id=51

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"
<http://www.gigamonkeys.com/book/practical-building-a-unit-test-framework.html>

(deftest arithmetic
  (addition)
  (subtraction))

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.


RUNNING 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 []
  (arithmetic))

Note: test-ns-hook prevents execution of fixtures (see below).


OMITTING TESTS FROM PRODUCTION CODE

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

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.


SAVING TEST OUTPUT TO A FILE

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
clojure.java.io/writer.


EXTENDING TEST-IS (ADVANCED)

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.walk


    
    
  

clojure.xml

by Rich Hickey
XML reading/writing.

clojure.zip

by Rich Hickey
Functional hierarchical zipper, with navigation, editing,
and enumeration.  See Huet

clojure.core.protocols


    
    
  

clojure.core.reducers

by Rich Hickey
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.

clojure.test.junit

by Jason Sankey
clojure.test extension for JUnit-compatible XML output.

JUnit (http://junit.org/) 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)

  (with-junit-output
    (run-tests 'my.cool.library))

To write the output to a file, rebind clojure.test/*test-out* to
your own PrintWriter (perhaps opened using
clojure.java.io/writer).

clojure.test.tap

by Stuart Sierra
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
http://testanything.org/ and
http://search.cpan.org/~petdance/TAP-1.0.0/TAP.pm

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)

  (with-tap-output
   (run-tests 'my.cool.library))


core.async


Project API Overview

clojure.core.async


    
    
  

clojure.core.async.lab

core.async HIGHLY EXPERIMENTAL feature exploration

Caveats:

1. Everything defined in this namespace is experimental, and subject
to change or deletion without warning.

2. Many features provided by this namespace are highly coupled to
implementation details of core.async. Potential features which
operate at higher levels of abstraction are suitable for inclusion
in the examples.

3. Features provided by this namespace MAY be promoted to
clojure.core.async at a later point in time, but there is no
guarantee any of them will.


core.cache


Project API Overview

clojure.core.cache

by Fogus
A caching library for Clojure.


core.contracts


Project API Overview

clojure.core.contracts

The public contracts programming functions and macros for clojure.core.contracts.

clojure.core.contracts.constraints


    
    
  

clojure.core.contracts.impl.transformers


    
    
  

clojure.core.contracts.impl.utils


    
    
  


core.incubator


Project API Overview

clojure.core.incubator

by Laurent Petit (and others)
Functions/macros variants of the ones that can be found in clojure.core 
(note to other contrib members: feel free to add to this lib)

clojure.core.strint

by Chas Emerick
Compile-time string interpolation for Clojure.


core.logic


Project API Overview

clojure.core.logic


    
    
  

clojure.core.logic.arithmetic


    
    
  

clojure.core.logic.bench


    
    
  

clojure.core.logic.fd


    
    
  

clojure.core.logic.nominal


    
    
  

clojure.core.logic.unifier


    
    
  


core.match


Project API Overview

clojure.core.match


    
    
  

clojure.core.match.java


    
    
  

clojure.core.match.protocols


    
    
  

clojure.core.match.regex


    
    
  


core.memoize


Project API Overview

clojure.core.memoize

by fogus
core.memoize is a memoization library offering functionality above Clojure's core `memoize`
function in the following ways:

**Pluggable memoization**

core.memoize allows for different back-end cache implmentations to be used as appropriate without
changing the memoization modus operandi.

**Manipulable memoization**

Because core.memoize allows you to access a function's memoization store, you do interesting things like
clear it, modify it, and save it for later.


core.rrb-vector


Project API Overview

clojure.core.rrb-vector

by Michał Marczyk
An implementation of the confluently persistent vector data
structure introduced in Bagwell, Rompf, "RRB-Trees: Efficient
Immutable Vectors", EPFL-REPORT-169879, September, 2011.

RRB-Trees build upon Clojure's PersistentVectors, adding logarithmic
time concatenation and slicing.

The main API entry points are clojure.core.rrb-vector/catvec,
performing vector concatenation, and clojure.core.rrb-vector/subvec,
which produces a new vector containing the appropriate subrange of
the input vector (in contrast to clojure.core/subvec, which returns
a view on the input vector).

core.rrb-vector's vectors can store objects or unboxed primitives.
The implementation allows for seamless interoperability with
clojure.lang.PersistentVector, clojure.core.Vec (more commonly known
as gvec) and clojure.lang.APersistentVector$SubVector instances:
clojure.core.rrb-vector/catvec and clojure.core.rrb-vector/subvec
convert their inputs to clojure.core.rrb-vector.rrbt.Vector
instances whenever necessary (this is a very fast constant time
operation for PersistentVector and gvec; for SubVector it is O(log
n), where n is the size of the underlying vector).

clojure.core.rrb-vector also exports its own versions of vector and
vector-of and vec which always produce
clojure.core.rrb-vector.rrbt.Vector instances. Note that vector-of
accepts :object as one of the possible type arguments, in addition
to keywords naming primitive types.

clojure.core.rrb-vector.rrbt


    
    
  


core.typed


Project API Overview

clojure.core.typed


    
    
  

clojure.core.typed.async

This namespace contains annotations and helper macros for type
checking core.async code. Ensure clojure.core.async is require'd
before performing type checking.

go
  use go>

chan
  use chan>

buffer
  use buffer> (similar for other buffer constructors)

clojure.core.typed.check.fn


    
    
  

clojure.core.typed.check.fn-method-utils


    
    
  

clojure.core.typed.check.funapp


    
    
  

clojure.core.typed.check.isa


    
    
  

clojure.core.typed.check.map


    
    
  

clojure.core.typed.check.recur-utils


    
    
  

clojure.core.typed.check.utils


    
    
  

clojure.core.typed.coerce-utils


    
    
  

clojure.core.typed.hole

This namespace contains easy tools for hole driven development

clojure.core.typed.load-if-needed


    
    
  

clojure.core.typed.ns-deps-utils


    
    
  

clojure.core.typed.open-result


    
    
  

clojure.core.typed.reset-caches


    
    
  

clojure.core.typed.util-vars


    
    
  


core.unify


Project API Overview

clojure.core.unify

by Michael Fogus
A unification library for Clojure.


data.avl


Project API Overview

clojure.data.avl

by Michał Marczyk
An implementation of persistent sorted maps and sets based on AVL
trees which can be used as drop-in replacements for Clojure's
built-in sorted maps and sets based on red-black trees. Apart from
the standard sorted collection API, the provided map and set types
support the transients API and several additional logarithmic time
operations: rank queries via clojure.core/nth (select element by
rank) and clojure.data.avl/rank-of (discover rank of element),
"nearest key" lookups via clojure.data.avl/nearest, splits by key
and index via clojure.data.avl/split-key and
clojure.data.avl/split-at, respectively, and subsets/submaps using
clojure.data.avl/subrange.


data.codec


Project API Overview

clojure.data.codec.base64

by Alex Taggart
Functions for working with base64 encodings.


data.csv


Project API Overview

clojure.data.csv

by Jonas Enlund
Reading and writing comma separated values.


data.finger-tree


Project API Overview

clojure.data.finger-tree

by Chris Houser
Persistent collections based on 2-3 finger trees.


data.fressian


Project API Overview

clojure.data.fressian

by Stuart Halloway
Read/write fressian data. See http://www.edn-format.org/


data.generators


Project API Overview

clojure.data.generators

by Stuart Halloway
Data generators for Clojure.


data.json


Project API Overview

clojure.data.json

by Stuart Sierra
JavaScript Object Notation (JSON) parser/generator.
See http://www.json.org/


data.priority-map


Project API Overview

clojure.data.priority-map

by Mark Engelberg
A priority map is very similar to a sorted map, but whereas a sorted map produces a
sequence of the entries sorted by key, a priority map produces the entries sorted by value.
In addition to supporting all the functions a sorted map supports, a priority map
can also be thought of as a queue of [item priority] pairs.  To support usage as
a versatile priority queue, priority maps also support conj/peek/pop operations.

The standard way to construct a priority map is with priority-map:
user=> (def p (priority-map :a 2 :b 1 :c 3 :d 5 :e 4 :f 3))
#'user/p
user=> p
{:b 1, :a 2, :c 3, :f 3, :e 4, :d 5}

So :b has priority 1, :a has priority 2, and so on.
Notice how the priority map prints in an order sorted by its priorities (i.e., the map's values)

We can use assoc to assign a priority to a new item:
user=> (assoc p :g 1)
{:b 1, :g 1, :a 2, :c 3, :f 3, :e 4, :d 5}

or to assign a new priority to an extant item:
user=> (assoc p :c 4)
{:b 1, :a 2, :f 3, :c 4, :e 4, :d 5}

We can remove an item from the priority map:
user=> (dissoc p :e)
{:b 1, :a 2, :c 3, :f 3, :d 5}

An alternative way to add to the priority map is to conj a [item priority] pair:
user=> (conj p [:g 0])
{:g 0, :b 1, :a 2, :c 3, :f 3, :e 4, :d 5}

or use into:
user=> (into p [[:g 0] [:h 1] [:i 2]])
{:g 0, :b 1, :h 1, :a 2, :i 2, :c 3, :f 3, :e 4, :d 5}

Priority maps are countable:
user=> (count p)
6

Like other maps, equivalence is based not on type, but on contents.
In other words, just as a sorted-map can be equal to a hash-map,
so can a priority-map.
user=> (= p {:b 1, :a 2, :c 3, :f 3, :e 4, :d 5})
true

You can test them for emptiness:
user=> (empty? (priority-map))
true
user=> (empty? p)
false

You can test whether an item is in the priority map:
user=> (contains? p :a)
true
user=> (contains? p :g)
false

It is easy to look up the priority of a given item, using any of the standard map mechanisms:
user=> (get p :a)
2
user=> (get p :g 10)
10
user=> (p :a)
2
user=> (:a p)
2

Priority maps derive much of their utility by providing priority-based seq.
Note that no guarantees are made about the order in which items of the same priority appear.
user=> (seq p)
([:b 1] [:a 2] [:c 3] [:f 3] [:e 4] [:d 5])
Because no guarantees are made about the order of same-priority items, note that
rseq might not be an exact reverse of the seq.  It is only guaranteed to be in
descending order.
user=> (rseq p)
([:d 5] [:e 4] [:c 3] [:f 3] [:a 2] [:b 1])

This means first/rest/next/for/map/etc. all operate in priority order.
user=> (first p)
[:b 1]
user=> (rest p)
([:a 2] [:c 3] [:f 3] [:e 4] [:d 5])

Priority maps support metadata:
user=> (meta (with-meta p {:extra :info}))
{:extra :info}

But perhaps most importantly, priority maps can also function as priority queues.
peek, like first, gives you the first [item priority] pair in the collection.
pop removes the first [item priority] from the collection.
(Note that unlike rest, which returns a seq, pop returns a priority map).

user=> (peek p)
[:b 1]
user=> (pop p)
{:a 2, :c 3, :f 3, :e 4, :d 5}

It is also possible to use a custom comparator:
user=> (priority-map-by > :a 1 :b 2 :c 3)
{:c 3, :b 2, :a 1}

Sometimes, it is desirable to have a map where the values contain more information
than just the priority.  For example, let's say you want a map like:
{:a [2 :apple], :b [1 :banana], :c [3 :carrot]}
and you want to sort the map by the numeric priority found in the pair.

A common mistake is to try to solve this with a custom comparator:
(priority-map 
  (fn [[priority1 _] [priority2 _]] (< priority1 priority2))
  :a [2 :apple], :b [1 :banana], :c [3 :carrot])

This will not work!  In Clojure, like Java, all comparators must be total orders,
meaning that you can't have a tie unless the objects you are comparing are
in fact equal.  The above comparator breaks that rule because
[2 :apple] and [2 :apricot] tie, but are not equal.

The correct way to construct such a priority map is by specifying a keyfn, which is used
to extract the true priority from the priority map's vals.  (Note: It might seem a little odd
that the priority-extraction function is called a *key*fn, even though it is applied to the
map's values.  This terminology is based on the docstring of clojure.core/sort-by, which
uses `keyfn` for the function which extracts the sort order.) 

In the above example,

user=> (priority-map-keyfn first :a [2 :apple], :b [1 :banana], :c [3 :carrot])
{:b [1 :banana], :a [2 :apple], :c [3 :carrot]}

You can also combine a keyfn with a comparator that operates on the extracted priorities:

user=> (priority-map-keyfn-by 
          first >
          :a [2 :apple], :b [1 :banana], :c [3 :carrot])
{:c [3 :carrot], :a [2 :apple], :b [1 :banana]}

 

All of these operations are efficient.  Generally speaking, most operations
are O(log n) where n is the number of distinct priorities.  Some operations
(for example, straightforward lookup of an item's priority, or testing
whether a given item is in the priority map) are as efficient
as Clojure's built-in map.

The key to this efficiency is that internally, not only does the priority map store
an ordinary hash map of items to priority, but it also stores a sorted map that
maps priorities to sets of items with that priority.

A typical textbook priority queue data structure supports at the ability to add
a [item priority] pair to the queue, and to pop/peek the next [item priority] pair.
But many real-world applications of priority queues require more features, such
as the ability to test whether something is already in the queue, or to reassign
a priority.  For example, a standard formulation of Dijkstra's algorithm requires the
ability to reduce the priority number associated with a given item.  Once you
throw persistence into the mix with the desire to adjust priorities, the traditional
structures just don't work that well.

This particular blend of Clojure's built-in hash sets, hash maps, and sorted maps
proved to be a great way to implement an especially flexible persistent priority queue.

Connoisseurs of algorithms will note that this structure's peek operation is not O(1) as
it would be if based upon a heap data structure, but I feel this is a small concession for
the blend of persistence, priority reassignment, and priority-sorted seq, which can be
quite expensive to achieve with a heap (I did actually try this for comparison).  Furthermore,
this peek's logarithmic behavior is quite good (on my computer I can do a million
peeks at a priority map with a million items in 750ms).  Also, consider that peek and pop
usually follow one another, and even with a heap, pop is logarithmic.  So the net combination
of peek and pop is not much different between this versatile formulation of a priority map and
a more limited heap-based one.  In a nutshell, peek, although not O(1), is unlikely to be the
bottleneck in your program.

All in all, I hope you will find priority maps to be an easy-to-use and useful addition
to Clojure's assortment of built-in maps (hash-map and sorted-map).


data.xml


Project API Overview

clojure.data.xml

by Chris Houser
Functions to parse XML into lazy sequences and lazy trees and
emit these as text.


data.zip


Project API Overview

clojure.data.zip

by Chris Houser
System for filtering trees and nodes generated by zip.clj in
general, and xml trees in particular.

clojure.data.zip.xml


    
    
  


java.classpath


Project API Overview

clojure.java.classpath

by Stuart Sierra
Utilities for dealing with the JVM's classpath


java.data


Project API Overview

clojure.java.data

by Cosmin Stejerean
Support for recursively converting Java beans to Clojure and vice versa.


java.jdbc


Project API Overview

clojure.java.jdbc

by Stephen C. Gilardi, Sean Corfield
A Clojure interface to SQL databases via JDBC

clojure.java.jdbc provides a simple abstraction for CRUD (create, read,
update, delete) operations on a SQL database, along with basic transaction
support. Basic DDL operations are also supported (create table, drop table,
access to table metadata).

Maps are used to represent records, making it easy to store and retrieve
data. Results can be processed using any standard sequence operations.

For most operations, Java's PreparedStatement is used so your SQL and
parameters can be represented as simple vectors where the first element
is the SQL string, with ? for each parameter, and the remaining elements
are the parameter values to be substituted. In general, operations return
the number of rows affected, except for a single record insert where any
generated keys are returned (as a map).

For more documentation, see:

http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html

As of release 0.3.0, the API has undergone a major overhaul and most of the
original API has been deprecated in favor of a more idiomatic API. The
original API has been moved to java.jdbc.deprecated for backward
compatibility but it will be removed before a 1.0.0 release.

clojure.java.jdbc.deprecated

by Stephen C. Gilardi, Sean Corfield
A Clojure interface to SQL databases via JDBC

This namespace contains the old API (0.2.3) which was deprecated in the 0.3.0
release and is provided for backward compatibility. This API will be removed
completely before a 1.0.0 release so will need to migrate code to the new API
before that release.

clojure.java.jdbc provides a simple abstraction for CRUD (create, read,
update, delete) operations on a SQL database, along with basic transaction
support. Basic DDL operations are also supported (create table, drop table,
access to table metadata).

Maps are used to represent records, making it easy to store and retrieve
data. Results can be processed using any standard sequence operations.

For most operations, Java's PreparedStatement is used so your SQL and
parameters can be represented as simple vectors where the first element
is the SQL string, with ? for each parameter, and the remaining elements
are the parameter values to be substituted. In general, operations return
the number of rows affected, except for a single record insert where any
generated keys are returned (as a map).


java.jmx


Project API Overview

clojure.java.jmx

by Stuart Halloway
JMX support for Clojure

Usage
  (require '[clojure.java.jmx :as jmx])

What beans do I have?

  (jmx/mbean-names "*:*")
  -> #<HashSet [java.lang:type=MemoryPool,name=CMS Old Gen,
                java.lang:type=Memory, ...]

What attributes does a bean have?

  (jmx/attribute-names "java.lang:type=Memory")
  -> (:Verbose :ObjectPendingFinalizationCount
      :HeapMemoryUsage :NonHeapMemoryUsage)

What is the value of an attribute?

  (jmx/read "java.lang:type=Memory" :ObjectPendingFinalizationCount)
  -> 0
  (jmx/read "java.lang:type=Memory" [:HeapMemoryUsage :NonHeapMemoryUsage])
  ->
  {:NonHeapMemoryUsage
    {:used 16674024, :max 138412032, :init 24317952, :committed 24317952},
   :HeapMemoryUsage
    {:used 18619064, :max 85393408, :init 0, :committed 83230720}}

Can't I just have *all* the attributes in a Clojure map?

  (jmx/mbean "java.lang:type=Memory")
  -> {:NonHeapMemoryUsage
       {:used 16674024, :max 138412032, :init 24317952, :committed 24317952},
      :HeapMemoryUsage
       {:used 18619064, :max 85393408, :init 0, :committed 83230720},
      :ObjectPendingFinalizationCount 0,
      :Verbose false}

Can I find and invoke an operation?

  (jmx/operation-names "java.lang:type=Memory")
  -> (:gc)
  (jmx/invoke "java.lang:type=Memory" :gc)
  -> nil

What about some other process? Just run *any* of the above code
inside a with-connection:

  (jmx/with-connection {:host "localhost", :port 3000}
    (jmx/mbean "java.lang:type=Memory"))
  -> {:ObjectPendingFinalizationCount 0,
      :HeapMemoryUsage ... etc.}

Can I serve my own beans?  Sure, just drop a Clojure ref
into an instance of clojure.java.jmx.Bean, and the bean
will expose read-only attributes for every key/value pair
in the ref:

  (jmx/register-mbean
     (create-bean
     (ref {:string-attribute "a-string"}))
     "my.namespace:name=Value")


math.combinatorics


Project API Overview

clojure.math.combinatorics

by Mark Engelberg
Efficient, functional algorithms for generating lazy
sequences for common combinatorial functions. (See the source code 
for a longer description.)


math.numeric-tower


Project API Overview

clojure.math.numeric-tower

by Mark Engelberg
Math functions that deal intelligently with the various
types in Clojure's numeric tower, as well as math functions
commonly found in Scheme implementations.

expt - (expt x y) is x to the yth power, returns an exact number
  if the base is an exact number, and the power is an integer,
  otherwise returns a double.
abs - (abs n) is the absolute value of n
gcd - (gcd m n) returns the greatest common divisor of m and n
lcm - (lcm m n) returns the least common multiple of m and n

When floor, ceil, and round are passed doubles, we just defer to
the corresponding functions in Java's Math library.  Java's
behavior is somewhat strange (floor and ceil return doubles rather
than integers, and round on large doubles yields spurious results)
but it seems best to match Java's semantics.  On exact numbers
(ratios and decimals), we can have cleaner semantics.

floor - (floor n) returns the greatest integer less than or equal to n.
  If n is an exact number, floor returns an integer,
  otherwise a double.
ceil - (ceil n) returns the least integer greater than or equal to n.
  If n is an exact number, ceil returns an integer,
  otherwise a double.
round - (round n) rounds to the nearest integer.
  round always returns an integer.  round rounds up for values
  exactly in between two integers.


sqrt - Implements the sqrt behavior I'm accustomed to from PLT Scheme,
  specifically, if the input is an exact number, and is a square
  of an exact number, the output will be exact.  The downside
  is that for the common case (inexact square root), some extra
  computation is done to look for an exact square root first.
  So if you need blazingly fast square root performance, and you
  know you're just going to need a double result, you're better
  off calling java's Math/sqrt, or alternatively, you could just
  convert your input to a double before calling this sqrt function.
  If Clojure ever gets complex numbers, then this function will
  need to be updated (so negative inputs yield complex outputs).
exact-integer-sqrt - Implements a math function from the R6RS Scheme
  standard.  (exact-integer-sqrt k) where k is a non-negative integer,
  returns [s r] where k = s^2+r and k < (s+1)^2.  In other words, it
  returns the floor of the square root and the "remainder".


test.generative


Project API Overview

clojure.test.generative


    
    
  

clojure.test.generative.runner


    
    
  


tools.analyzer


Project API Overview

clojure.tools.analyzer

Analyzer for clojure code, host agnostic.

Entry point:
* analyze

Platform implementers must provide dynamic bindings for:
* macroexpand-1
* parse
* create-var
* var?

Setting up the global env is also required, see clojure.tools.analyzer.env

See clojure.tools.analyzer.core-test for an example on how to setup the analyzer.

clojure.tools.analyzer.ast

Utilities for AST walking/updating

clojure.tools.analyzer.ast.query

Utilities for querying tools.analyzer ASTs with Datomic

clojure.tools.analyzer.env


    
    
  

clojure.tools.analyzer.passes.add-binding-atom


    
    
  

clojure.tools.analyzer.passes.collect


    
    
  

clojure.tools.analyzer.passes.constant-lifter


    
    
  

clojure.tools.analyzer.passes.elide-meta


    
    
  

clojure.tools.analyzer.passes.emit-form


    
    
  

clojure.tools.analyzer.passes.index-vector-nodes


    
    
  

clojure.tools.analyzer.passes.source-info


    
    
  

clojure.tools.analyzer.passes.trim


    
    
  

clojure.tools.analyzer.passes.uniquify


    
    
  

clojure.tools.analyzer.passes.warn-earmuff


    
    
  

clojure.tools.analyzer.utils


    
    
  


tools.analyzer.jvm


Project API Overview

clojure.tools.analyzer.jvm

Analyzer for clojure code, extends tools.analyzer with JVM specific passes/forms

clojure.tools.analyzer.jvm.utils


    
    
  


tools.cli


Project API Overview

clojure.tools.cli

by Gareth Jones, Sung Pae
Tools for working with command line arguments.


tools.emitter.jvm


Project API Overview

clojure.tools.emitter.jvm


    
    
  

clojure.tools.emitter.jvm.emit


    
    
  


tools.logging


Project API Overview

clojure.tools.logging

by Alex Taggart
Logging macros which delegate to a specific logging implementation. At
runtime a specific implementation is selected from, in order, slf4j,
Apache commons-logging, log4j, and finally java.util.logging.

The logging implementation can be expliticly determined by using
binding or alter-var-root to change the value of *logger-factory* to
another implementation of clojure.tools.logging.impl/LoggerFactory
(see also the *-factory functions in the impl namespace).

clojure.tools.logging.impl

by Alex Taggart
Protocols used to allow access to logging implementations.
This namespace only need be used by those providing logging
implementations to be consumed by the core api.


tools.macro


Project API Overview

clojure.tools.macro

by Konrad Hinsen
Local macros and symbol macros

Local macros are defined by a macrolet form. They are usable only
inside its body. Symbol macros can be defined globally
(defsymbolmacro) or locally (symbol-macrolet). A symbol
macro defines a form that replaces a symbol during macro
expansion. Function arguments and symbols bound in let
forms are not subject to symbol macro expansion.

Local macros are most useful in the definition of the expansion
of another macro, they may be used anywhere. Global symbol
macros can be used only inside a with-symbol-macros form.


tools.namespace


Project API Overview

clojure.tools.namespace

by Stuart Sierra
This namespace is DEPRECATED; most functions have been moved to
other namespaces

clojure.tools.namespace.dependency

by Stuart Sierra
Bidirectional graphs of dependencies and dependent objects.

clojure.tools.namespace.dir

by Stuart Sierra
Track namespace dependencies and changes by monitoring
file-modification timestamps

clojure.tools.namespace.file

by Stuart Sierra
Read and track namespace information from files

clojure.tools.namespace.find

by Stuart Sierra
Search for namespace declarations in directories and JAR files.

clojure.tools.namespace.move

by Stuart Sierra
Refactoring tool to move a Clojure namespace from one name/file to
another, and update all references to that namespace in your other
Clojure source files.

WARNING: This code is ALPHA and subject to change. It also modifies
and deletes your source files! Make sure you have a backup or
version control.

clojure.tools.namespace.parse

by Stuart Sierra
Parse Clojure namespace (ns) declarations and extract
dependencies.

clojure.tools.namespace.reload

by Stuart Sierra
Force reloading namespaces on demand or through a
dependency tracker

clojure.tools.namespace.repl

by Stuart Sierra
REPL utilities for working with namespaces

clojure.tools.namespace.track

by Stuart Sierra
Dependency tracker which can compute which namespaces need to be
reloaded after files have changed. This is the low-level
implementation that requires you to find the namespace dependencies
yourself: most uses will interact with the wrappers in
clojure.tools.namespace.file and clojure.tools.namespace.dir or the
public API in clojure.tools.namespace.repl.


tools.nrepl


Project API Overview

clojure.tools.nrepl

by Chas Emerick
High level nREPL client support.

clojure.tools.nrepl.ack


    
    
  

clojure.tools.nrepl.bencode

by Meikel Brandmeyer
A netstring and bencode implementation for Clojure.

clojure.tools.nrepl.cmdline

by Chas Emerick
A proof-of-concept command-line client for nREPL.  Please see
e.g. reply for a proper command-line nREPL client @
https://github.com/trptcolin/reply/

clojure.tools.nrepl.helpers

by Chas Emerick

    
    
  

clojure.tools.nrepl.middleware


    
    
  

clojure.tools.nrepl.middleware.interruptible-eval

by Chas Emerick

    
    
  

clojure.tools.nrepl.middleware.load-file

by Chas Emerick

    
    
  

clojure.tools.nrepl.middleware.pr-values

by Chas Emerick

    
    
  

clojure.tools.nrepl.middleware.session

by Chas Emerick
Support for persistent, cross-connection REPL sessions.

clojure.tools.nrepl.misc

by Chas Emerick
Misc utilities used in nREPL's implementation (potentially also useful
for anyone extending it).

clojure.tools.nrepl.server

by Chas Emerick
Default server implementations

clojure.tools.nrepl.transport

by Chas Emerick

    
    
  


tools.reader


Project API Overview

clojure.tools.reader

by Bronsa
A clojure reader in clojure

clojure.tools.reader.edn

by Bronsa
An EDN reader in clojure

clojure.tools.reader.reader-types

by Bronsa
Protocols and default Reader types implementation


tools.trace


Project API Overview

clojure.tools.trace

by Stuart Sierra, Michel Salim, Luc Préfontaine, Jonathan Fischer Friberg, Michał Marczyk, Don Jackson
This file defines simple tracing macros to help you see what your code is doing.
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.