API Overview - ()
The user contributions library, clojure.contrib, is a collection
of namespaces each of which implements features that we believe may be useful to
a large part of the clojure community.
This library was created by Rich Hickey but has been populated and is maintained by a
group of volunteers who are excited about the success of the Clojure language and
want to do our part to help it along. The current list of contributors is available
on the
clojure-contrib GitHub source page.
More contributions (and contributors) are welcome. If you wish to contribute, you will need
to sign a contributor agreement (which allows Clojure and clojure.contrib to proceed
without entanglements, see
contributing
for more info).
The best way to start is to share a project you've written with the google group and gauge
the interest in adding it to contrib. (Publishing it in an open source form on google code,
github or some other easy-to-access place in the net will also help.) After general
discussion, Rich Hickey makes the final determination about what gets added to
clojure.contrib.
Some parts of clojure.contrib may migrate into clojure.core if they prove to be so
generally useful that they justify being everywhere. (For example, condp started out
as an extension in contrib, but was moved to core by popular acclamation.)
The exact role of clojure.contrib and the future of the Clojure environment (standard
libraries, dependency models, packaging systems, etc.)
is the subject of pretty much continuous discussion
in the clojure google group and in #clojure on freenode. Feel free to join that
discussion and help shape the ways Clojure is extended.
Like Clojure itself, clojure.contrib is made available under the
Eclipse Public License (EPL).
clojure.contrib is copyright 2008-2009 Rich Hickey and the various contributors.
Important clojure-contrib resources
agent-utils
by Christophe Grande
Detailed API documentation
Miscellaneous agent utilities
(note to other contrib members: feel free to add to this lib)
Public variables and functions:
capture-and-send
apply-macro
Detailed API documentation
Deprecated since clojure-contrib version 1.2
Public variables and functions:
apply-macro
base64
by Stuart Sierra
Detailed API documentation
Base-64 encoding and (maybe later) decoding.
This is mainly here as an example. It is much slower than the
Apache Commons Codec implementation or sun.misc.BASE64Encoder.
Public variables and functions:
encode encode-str
classpath
by Stuart Sierra
Detailed API documentation
Utilities for dealing with the JVM's classpath
Public variables and functions:
classpath classpath-directories classpath-jarfiles
combinatorics
by Mark Engelberg
Detailed API documentation
Efficient, functional algorithms for generating lazy
sequences for common combinatorial functions. (See the source code
for a longer description.)
Public variables and functions:
cartesian-product combinations lex-permutations permutations selections subsets
command-line
by Chris Houser
Detailed API documentation
Process command-line arguments according to a given cmdspec
Public variables and functions:
with-command-line
complex-numbers
by Konrad Hinsen
Detailed API documentation
Complex numbers
NOTE: This library is in evolution. Most math functions are
not implemented yet.
Public variables and functions:
cond
by Stephen C. Gilardi
Detailed API documentation
Extensions to the basic cond function.
Public variables and functions:
cond-let
condition
by Stephen C. Gilardi
Detailed API documentation
Flexible raising and handling of conditions:
Functions:
raise: raises a condition
handler-case: dispatches raised conditions to appropriate handlers
print-stack-trace: prints abbreviated or full condition stack traces
Data:
A condition is a map containing values for these keys:
- :type, a condition type specifier, typically a keyword
- :stack-trace, a stack trace to the site of the raise
- :message, a human-readable message (optional)
- :cause, a wrapped exception or condition (optional)
- other keys given as arguments to raise (optional)
Note: requires AOT compilation.
Based on an idea from Chouser:
http://groups.google.com/group/clojure/browse_frm/thread/da1285c538f22bb5
Public variables and functions:
*full-stack-traces* handler-case print-stack-trace raise stack-trace-info
Variables and functions in
condition.Condition:
-init
-meta
-post-init
core
by Laurent Petit (and others)
Detailed API documentation
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)
Public variables and functions:
-?> -?>> .?. dissoc-in new-by-name seqable?
duck-streams
by Stuart Sierra
Detailed API documentation
This file defines "duck-typed" I/O utility functions for Clojure.
The 'reader' and 'writer' functions will open and return an
instance of java.io.BufferedReader and java.io.PrintWriter,
respectively, for a variety of argument types -- filenames as
strings, URLs, java.io.File's, etc. 'reader' even works on http
URLs.
Note: this is not really "duck typing" as implemented in languages
like Ruby. A better name would have been "do-what-I-mean-streams"
or "just-give-me-a-stream", but ducks are funnier.
Deprecated since clojure-contrib version 1.2
Public variables and functions:
*append-to-writer* *buffer-size* *byte-array-type* *default-encoding* append-spit append-writer copy file-str make-parents pwd read-lines reader slurp* spit to-byte-array with-in-reader with-out-append-writer with-out-writer write-lines writer
error-kit
by Chris Houser
Detailed API documentation
EXPERIMENTAL
System for defining and using custom errors
Please contact Chouser if you have any suggestions for better names
or API adjustments.
Public variables and functions:
bind-continue deferror do-not-handle error handle raise raise* throw-msg with-handler
except
by Stephen C. Gilardi
Detailed API documentation
Provides functions that make it easy to specify the class, cause, and
message when throwing an Exception or Error. The optional message is
formatted using clojure.core/format.
Public variables and functions:
throw-arg throw-if throw-if-not throwf
fcase
by Stuart Sierra
Detailed API documentation
This file defines a generic "case" macro called "fcase" which takes
the equality-testing function as an argument. It also defines a
traditional "case" macro that tests using "=" and variants that
test for regular expressions and class membership.
Note (December 23, 2008): This library has been supplanted by the
inclusion of "condp" in clojure.core as of Clojure SVN rev. 1180.
Public variables and functions:
case fcase in-case instance-case re-case
fnmap
by Stuart Sierra
Detailed API documentation
Maps that dispatch get/assoc to user-defined functions.
Note: requires AOT-compilation
Public variables and functions:
fnmap
gen-html-docs
by Craig Andera
Detailed API documentation
Generates a single HTML page that contains the documentation for
one or more Clojure libraries.
Public variables and functions:
generate-documentation generate-documentation-to-file
generic.arithmetic
by Konrad Hinsen
Detailed API documentation
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.
Public variables and functions:
* + - / defmethod* qsym
generic.collection
by Konrad Hinsen
Detailed API documentation
Generic arithmetic interface
This library defines generic versions of common
collection-related functions as multimethods that can be
defined for any type.
Public variables and functions:
assoc conj dissoc empty get into seq
generic.comparison
by Konrad Hinsen
Detailed API documentation
Generic comparison interface
This library defines generic versions of = < > <= >= zero?
as multimethods that can be defined for any type. Of the
greater/less-than relations, types must minimally implement >.
Public variables and functions:
< <= = > >= max min neg? pos? zero?
generic.functor
by Konrad Hinsen
Detailed API documentation
Generic functor interface (fmap)
Public variables and functions:
fmap
generic.math-functions
by Konrad Hinsen
Detailed API documentation
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.
Public variables and functions:
abs acos approx= asin atan atan2 ceil conjugate cos exp floor log pow rint round sgn sin sqr sqrt tan
greatest-least
by Vincent Foley
Detailed API documentation
Various functions for finding greatest and least values in a collection
Public variables and functions:
all-greatest all-greatest-by all-least all-least-by greatest greatest-by least least-by
http.agent
by Stuart Sierra
Detailed API documentation
Agent-based asynchronous HTTP client.
This is a HTTP client library based on Java's HttpURLConnection
class and Clojure's Agent system. It allows you to make multiple
HTTP requests in parallel.
Start an HTTP request with the 'http-agent' function, which
immediately returns a Clojure Agent. You will never deref this
agent; that is handled by the accessor functions. The agent will
execute the HTTP request on a separate thread.
If you pass a :handler function to http-agent, that function will be
called as soon as the HTTP response body is ready. The handler
function is called with one argument, the HTTP agent itself. The
handler can read the response body by calling the 'stream' function
on the agent.
The value returned by the handler function becomes part of the state
of the agent, and you can retrieve it with the 'result' function.
If you call 'result' before the HTTP request has finished, it will
block until the handler function returns.
If you don't provide a handler function, the default handler will
buffer the entire response body in memory, which you can retrieve
with the 'bytes', 'string', or 'stream' functions. Like 'result',
these functions will block until the HTTP request is completed.
If you want to check if an HTTP request is finished without
blocking, use the 'done?' function.
A single GET request could be as simple as:
(string (http-agent "http://www.stuartsierra.com/"))
A simple POST might look like:
(http-agent "http..." :method "POST" :body "foo=1")
And you could write the response directly to a file like this:
(require '[clojure.contrib.io :as d])
(http-agent "http..."
:handler (fn [agnt]
(with-open [w (d/writer "/tmp/out")]
(d/copy (stream agnt) w))))
Deprecated since clojure-contrib version 1.2
Public variables and functions:
buffer-bytes bytes client-error? done? error? headers headers-seq http-agent message method redirect? request-body request-headers request-uri result server-error? status stream string success?
http.connection
Detailed API documentation
Low-level HTTP client API around HttpURLConnection
Deprecated since clojure-contrib version 1.2
Public variables and functions:
http-connection send-request-entity
import-static
by Stuart Sierra
Detailed API documentation
Import static Java methods/fields into Clojure
Public variables and functions:
import-static
io
by Stuart Sierra
Detailed API documentation
This file defines polymorphic I/O utility functions for Clojure.
The Streams protocol defines reader, writer, input-stream and
output-stream methods that return BufferedReader, BufferedWriter,
BufferedInputStream and BufferedOutputStream instances (respectively),
with default implementations extended to a variety of argument
types: URLs or filenames as strings, java.io.File's, Sockets, etc.
Public variables and functions:
*append* *buffer-size* *byte-array-type* *char-array-type* *default-encoding* append-output-stream append-spit append-writer as-url copy delete-file delete-file-recursively file file-str input-stream make-parents output-stream pwd read-lines reader relative-path-string slurp* spit to-byte-array with-in-reader with-out-append-writer with-out-writer write-lines writer
jar
by Stuart Sierra
Detailed API documentation
Utilities for working with Java JAR files
Public variables and functions:
filenames-in-jar jar-file?
java-utils
by Stuart Halloway, Stephen C. Gilardi, Shawn Hoover, Perry Trolard, Stuart Sierra
Detailed API documentation
A set of utilties for dealing with Java stuff like files and properties.
Design goals:
(1) Ease-of-use. These APIs should be convenient. Performance is secondary.
(2) Duck typing. I hate having to think about the difference between
a string that names a file, and a File. Ditto for a ton of other
wrapper classes in the Java world (URL, InternetAddress). With these
APIs you should be able to think about domain equivalence, not type
equivalence.
(3) No bossiness. I am not marking any of these functions as private
the docstrings will tell you the intended usage but do what works for you.
Feedback welcome!
If something in this module violates the principle of least surprise, please
let me (Stu) and the Clojure community know via the mailing list.
Contributors:
Stuart Halloway
Stephen C. Gilardi
Shawn Hoover
Perry Trolard
Stuart Sierra
Public variables and functions:
as-file as-properties as-str as-url delete-file delete-file-recursively file get-system-property read-properties relative-path-string set-system-properties wall-hack-field wall-hack-method with-system-properties write-properties
javadoc.browse
by Christophe Grand
Detailed API documentation
Start a web browser from Clojure
Deprecated since clojure-contrib version 1.2
Public variables and functions:
open-url-in-browser open-url-in-swing
jmx
by Stuart Halloway
Detailed API documentation
JMX support for Clojure
Requires post-Clojure 1.0 git edge for clojure.test, clojure.backtrace.
This is prerelease.
This API will change.
Send reports to stu@thinkrelevance.com.
Usage
(require '[clojure.contrib.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
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.contrib.jmx.Bean, and the bean
will expose read-only attributes for every key/value pair
in the ref:
(jmx/register-mbean
(Bean.
(ref {:string-attribute "a-string"}))
"my.namespace:name=Value")
Public variables and functions:
*connection* as-object-name attribute-info attribute-names build-attribute-info guess-attribute-typename jmx->clj jmx-url map->attribute-infos maybe-atomize maybe-keywordize mbean mbean-names op-param-types operation operation-names operations raw-read read read-supported readable? with-connection
json
by Stuart Sierra
Detailed API documentation
JavaScript Object Notation (JSON) parser/writer.
See http://www.json.org/
To write JSON, use json-str, write-json, or write-json.
To read JSON, use read-json.
Public variables and functions:
json-str pprint-json print-json read-json read-json-from write-json
lazy-seqs
by Stephen C. Gilardi
Detailed API documentation
==== Lazy sequences ====
primes - based on the "naive" implemention described in [1] plus a
small "wheel" which eliminates multiples of 2, 3, 5, and
7 from consideration by incrementing past them. Also inspired
by code from Christophe Grand in [2].
fibs - all the Fibonacci numbers
powers-of-2 - all the powers of 2
==== Lazy sequence functions ====
(partition-all, shuffle moved to clojure.core)
(rand-elt moved to clojure.core/rand-nth)
(rotations, rand-elt moved to seq_utils.clj)
(permutations and combinations moved to combinatorics.clj)
[1] http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
[2] http://clj-me.blogspot.com/2008/06/primes.html
Public variables and functions:
fibs powers-of-2 primes
lazy-xml
by Chris Houser
Detailed API documentation
Functions to parse xml lazily and emit back to text.
Public variables and functions:
parse-seq parse-trim
logging
by Alex Taggart, Timothy Pratley
Detailed API documentation
Logging macros which delegate to a specific logging implementation. At
runtime a specific implementation is selected from, in order, Apache
commons-logging, log4j, and finally java.util.logging.
Logging levels are specified by clojure keywords corresponding to the
values used in log4j and commons-logging:
:trace, :debug, :info, :warn, :error, :fatal
Logging occurs with the log macro, or the level-specific convenience macros,
which write either directly or via an agent. For performance reasons, direct
logging is enabled by default, but setting the *allow-direct-logging* boolean
atom to false will disable it. If logging is invoked within a transaction it
will always use an agent.
The log macros will not evaluate their 'message' unless the specific logging
level is in effect. Alternately, you can use the spy macro when you have code
that needs to be evaluated, and also want to output the code and its result to
the debug log.
Unless otherwise specified, the current namespace (as identified by *ns*) will
be used as the log-ns (similar to how the java class name is usually used).
Note: your log configuration should display the name that was passed to the
logging implementation, and not perform stack-inspection, otherwise you'll see
something like "fn__72$impl_write_BANG__39__auto____81" in your logs.
Use the enabled? macro to write conditional code against the logging level
(beyond simply whether or not to call log, which is handled automatically).
You can redirect all java writes of System.out and System.err to the log
system by calling log-capture!. To rebind *out* and *err* to the log system
invoke with-logs. In both cases a log-ns (e.g., "com.example.captured")
needs to be specified to namespace the output.
Public variables and functions:
*allow-direct-logging* *impl-name* *logging-agent* debug enabled? error fatal impl-enabled? impl-get-log impl-write! info log log-capture! log-stream log-uncapture! spy trace warn with-logs
macro-utils
by Konrad Hinsen
Detailed API documentation
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.
Public variables and functions:
defsymbolmacro deftemplate macrolet mexpand mexpand-1 mexpand-all symbol-macrolet with-symbol-macros
macros
by Konrad Hinsen
Detailed API documentation
Various small macros
Public variables and functions:
const letfn- with-direct-linking
map-utils
by Jason Wolfe, Chris Houser
Detailed API documentation
Utilities for operating on Clojure maps.
Public variables and functions:
deep-merge-with lazy-get safe-get safe-get-in
math
by Mark Engelberg
Detailed API documentation
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
The behavior of the next three functions on doubles is consistent
with the behavior of the corresponding functions
in Java's Math library, but on exact numbers, returns an integer.
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
Public variables and functions:
abs ceil exact-integer-sqrt expt floor gcd lcm round sqrt
miglayout
by Stephen C. Gilardi
Detailed API documentation
Clojure support for the MiGLayout layout manager
http://www.miglayout.com/
Example:
(use '[clojure.contrib.miglayout.test :as mlt :only ()])
(dotimes [i 5] (mlt/run-test i))
Public variables and functions:
components miglayout
Variables and functions in
miglayout.internal:
add-components
component?
constraint?
do-layout
format-constraint
format-constraints
get-components
parse-component-constraint
parse-item-constraints
mmap
by Chris Houser
Detailed API documentation
Functions for memory-mapping files, plus some functions that use a
mmaped file for "normal" activies -- slurp, load-file, etc.
Public variables and functions:
buffer-stream mmap slurp
monadic-io-streams
by Konrad Hinsen
Detailed API documentation
Monadic I/O with Java input/output streams
Defines monadic I/O statements to be used in a state monad
with an input or output stream as the state. The macro
monadic-io creates a stream, runs a monadic I/O statement
on it, and closes the stream. This structure permits the
definition of purely functional compound I/O statements
which are applied to streams that can never escape from the
monadic statement sequence.
Public variables and functions:
flush print println read-char read-line read-lines skip-chars with-io-streams with-reader with-writer write
ns-utils
by Stephen C. Gilardi
Detailed API documentation
Namespace utilities
get-ns returns the namespace named by a symbol or throws
if the namespace does not exist
ns-vars returns a sorted seq of symbols naming public vars
in a namespace
print-docs prints documentation for the public vars in a
namespace
immigrate Create a public var in this namespace for each
public var in the namespaces named by ns-names.
From James Reeves
vars returns a sorted seq of symbols naming public vars
in a namespace (macro)
docs prints documentation for the public vars in a
namespace (macro)
Public variables and functions:
dir docs get-ns immigrate ns-vars print-dir print-docs vars
pprint
by Tom Faulhaber
Detailed API documentation
This module comprises two elements:
1) A pretty printer for Clojure data structures, implemented in the
function "pprint"
2) A Common Lisp compatible format function, implemented as
"cl-format" because Clojure is using the name "format"
for its Java-based format function.
See documentation for those functions for more information or complete
documentation on the the clojure-contrib web site on github.
Deprecated since clojure-contrib version 1.2
Public variables and functions:
*code-dispatch* *print-base* *print-circle* *print-lines* *print-miser-width* *print-pprint-dispatch* *print-pretty* *print-radix* *print-right-margin* *print-shared* *print-suppress-namespaces* *simple-dispatch* cl-format compile-format formatter formatter-out fresh-line pp pprint pprint-indent pprint-logical-block pprint-newline pprint-tab set-pprint-dispatch use-method with-pprint-dispatch write write-out
probabilities.finite-distributions
by Konrad Hinsen
Detailed API documentation
Finite probability distributions
This library defines a monad for combining finite probability
distributions.
Public variables and functions:
certainly choose cond-dist-m cond-prob dist-m join-with make-distribution normalize prob uniform zipf
probabilities.monte-carlo
by Konrad Hinsen
Detailed API documentation
Monte-Carlo method support
Monte-Carlo methods transform an input random number stream
(usually having a continuous uniform distribution in the
interval [0, 1)) into a random number stream whose distribution
satisfies certain conditions (usually the expectation value
is equal to some desired quantity). They are thus
transformations from one probability distribution to another one.
This library represents a Monte-Carlo method by a function that
takes as input the state of a random number stream with
uniform distribution (see
clojure.contrib.probabilities.random-numbers) and returns a
vector containing one sample value of the desired output
distribution and the final state of the input random number
stream. Such functions are state monad values and can be
composed using operations defined in clojure.contrib.monads.
Public variables and functions:
discrete exponential lognormal n-sphere normal normal-box-muller random-stream reject sample sample-mean sample-mean-variance sample-reduce sample-sum
probabilities.random-numbers
by Konrad Hinsen
Detailed API documentation
Random number streams
This library provides random number generators with a common
stream interface. They all produce pseudo-random numbers that are
uniformly distributed in the interval [0, 1), i.e. 0 is a
possible value but 1 isn't. For transformations to other
distributions, see clojure.contrib.probabilities.monte-carlo.
At the moment, the only generator provided is a rather simple
linear congruential generator.
Public variables and functions:
lcg rand-stream
profile
by Stuart Sierra
Detailed API documentation
Simple code profiling & timing measurement.
Wrap any section of code in the prof macro, giving it a name, like this:
(defn my-function [x y]
(let [sum (prof :addition (+ x y))
product (prof :multiplication (* x y))]
[sum product]))
The run your code in the profile macro, like this:
(profile (dotimes [i 10000] (my-function 3 4)))
Which prints a report for each named section of code:
Name mean min max count sum
addition 265 0 37000 10000 2655000
multiplication 274 0 53000 10000 2747000
Times are measured in nanoseconds, to the maximum precision available
under the JVM. See the function documentation for more details.
Public variables and functions:
*enable-profiling* print-summary prof profile summarize with-profile-data
prxml
by Stuart Sierra
Detailed API documentation
Compact syntax for generating XML. See the documentation of "prxml"
for details.
Public variables and functions:
*html-compatible* *prxml-indent* prxml
repl-ln
by Stephen C. Gilardi
Detailed API documentation
A repl with that provides support for lines and line numbers in the
input stream.
Public variables and functions:
print-repl-info repl repl-info repl-prompt set-repl-name set-repl-prompt stream-repl
server-socket
by Craig McDaniel
Detailed API documentation
Server socket library - includes REPL on socket
Public variables and functions:
create-repl-server create-server
set
by Jason Wolfe
Detailed API documentation
Clojure functions for operating on sets (supplemental to clojure.set)
Public variables and functions:
proper-subset? proper-superset? subset? superset?
shell
by Chris Houser
Detailed API documentation
Conveniently launch a sub-process providing to its stdin and
collecting its stdout
Deprecated since clojure-contrib version 1.2
Public variables and functions:
sh
shell-out
by Chris Houser
Detailed API documentation
Conveniently launch a sub-process providing to its stdin and
collecting its stdout
Deprecated since clojure-contrib version 1.2
Public variables and functions:
sh
singleton
by Stuart Sierra
Detailed API documentation
Singleton functions
Public variables and functions:
global-singleton per-thread-singleton
str-utils
by Stuart Sierra
Detailed API documentation
String utilities for Clojure
Deprecated since clojure-contrib version 1.2
Public variables and functions:
chomp chop re-gsub re-partition re-split re-sub str-join
str-utils2
by Stuart Sierra
Detailed API documentation
This is a library of string manipulation functions. It
is intented as a replacement for clojure.contrib.str-utils.
You cannot (use 'clojure.contrib.str-utils2) because it defines
functions with the same names as functions in clojure.core.
Instead, do (require '[clojure.contrib.str-utils2 :as s])
or something similar.
Goals:
1. Be functional
2. String argument first, to work with ->
3. Performance linear in string length
Some ideas are borrowed from
http://github.com/francoisdevlin/devlinsf-clojure-utils/
Deprecated since clojure-contrib version 1.2
Public variables and functions:
blank? butlast capitalize chomp chop codepoints contains? dochars docodepoints drop escape get grep join lower-case ltrim map-str partial partition repeat replace replace-first reverse rtrim split split-lines swap-case tail take trim upper-case
stream-utils
by Konrad Hinsen
Detailed API documentation
Functions for setting up computational pipelines via data streams.
NOTE: This library is experimental. It may change significantly
with future release.
This library defines:
- an abstract stream type, whose interface consists of the
multimethod stream-next
- a macro for implementing streams
- implementations of stream for
1) Clojure sequences, and vectors
2) nil, representing an empty stream
- tools for writing stream transformers, including the
monad stream-m
- various utility functions for working with streams
Streams are building blocks in the construction of computational
pipelines. A stream is represented by its current state plus
a function that takes a stream state and obtains the next item
in the stream as well as the new stream state. The state is
implemented as a Java class or a Clojure type (as defined by the
function clojure.core/type), and the function is provided as an
implementation of the multimethod stream-next for this class or type.
While setting up pipelines using this mechanism is somewhat more
cumbersome than using Clojure's lazy seq mechanisms, there are a
few advantages:
- The state of a stream can be stored in any Clojure data structure,
and the stream can be re-generated from it any number of times.
Any number of states can be stored this way.
- The elements of the stream are never cached, so keeping a reference
to a stream state does not incur an uncontrollable memory penalty.
Note that the stream mechanism is thread-safe as long as the
concrete stream implementations do not use any mutable state.
Stream transformers take any number of input streams and produce one
output stream. They are typically written using the stream-m
monad. In the definition of a stream transformer, (pick s) returns
the next value of stream argument s, whereas pick-all returns the
next value of all stream arguments in the form of a vector.
Public variables and functions:
defst defstream pick pick-all stream-drop stream-filter stream-flatten stream-m stream-map stream-next stream-seq stream-type
strint
by Chas Emerick
Detailed API documentation
String interpolation for Clojure.
Public variables and functions:
<<
test-is
by Stuart Sierra
Detailed API documentation
Backwards-compatibility for clojure.contrib.test-is
The clojure.contrib.test-is library moved from Contrib into the
Clojure distribution as clojure.test.
This happened on or around clojure-contrib Git commit
82cf0409d0fcb71be477ebfc4da18ee2128a2ad1 on June 25, 2009.
This file makes the clojure.test interface available under the old
namespace clojure.contrib.test-is.
This includes support for the old syntax of the 'are' macro.
This was suggested by Howard Lewis Ship in ticket #26,
http://www.assembla.com/spaces/clojure-contrib/tickets/26
Deprecated since clojure-contrib version 1.2
Public variables and functions:
*load-tests* *stack-trace-depth* apply-template are assert-any assert-predicate compose-fixtures deftest deftest- do-template file-position find-holes find-pure-exprs find-symbols flatten-map function? get-possibly-unbound-var inc-report-counter is join-fixtures report run-all-tests run-tests set-test successful? template? test-all-vars test-ns test-var testing testing-contexts-str testing-vars-str try-expr use-fixtures with-test with-test-out
trace
by Stuart Sierra, Michel Salim
Detailed API documentation
This file defines simple "tracing" macros to help you see what your
code is doing.
Public variables and functions:
*trace-depth* deftrace dotrace trace trace-fn-call trace-indent tracer
types
by Konrad Hinsen
Detailed API documentation
General and algebraic data types
Public variables and functions:
defadt deftype deftype- match
with-ns
by Stuart Sierra
Detailed API documentation
Temporary namespace macro
Public variables and functions:
with-ns with-temp-ns
zip-filter
by Chris Houser
Detailed API documentation
System for filtering trees and nodes generated by zip.clj in
general, and xml trees in particular.
Public variables and functions:
ancestors children children-auto descendants left-locs leftmost? right-locs rightmost?
Variables and functions in
zip-filter.xml:
attr
attr=
seq-test
tag=
text
text=
xml->
xml1->