411 REFERENCE · Wikibooks
Clojure Programming/Examples/API Examples
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
This page gives example usage for Clojure API function calls. For a more general introduction to Clojure by example please see
http://en.wikibooks.org/wiki/Clojure_Programming/By_Example
Documentation
This page provides examples for the following functions.
doc
find-doc
source
Data Structures
Numbers
Computation + - * / inc dec min max rem rationalize Comparison ==<]]>]]<=]]>=]] Predicates zero? pos? neg?
Strings
str
Characters
Advanced Data Structures
Lists
Vectors
Maps
get
assoc-in
merge
Struct Maps
accessor
assoc
defstruct
struct
struct-map
Array Maps
Sets
union
Zippers
zipper
zipmap
Sequences
interpose
interleave
reverse
butlast
replace
Sequence Building
conj
concat
merge
Mapping Operators
This page provides examples for the following functions.
map
reduce
apply
Macros
[[Clojure Programming/Examples/API Examples/Macros#->|->]]
[[Clojure Programming/Examples/API Examples/Macros#->|cond]]
[[Clojure Programming/Examples/API Examples/Macros#->|condp]]
do Macros
This page provides examples for the following functions.
doseq
doall
dorun
doto
Variable Definition
This page provides examples for the following functions.
def
binding
MultiMethod
This page defines the following functions
defmulti
defmethod
Reference Tools
This page defines the following functions.
ref
ref-set
deref
@
delay
force
commute
Predicate functions
This page provides examples for the following functions.
drop-while
filter
not-any
remove
every?
some
Recursion Tools
This page defines the following functions.
loop
recur
lazy-cons
Function Tools
This page provides examples for the following functions.
fn
#()
"lambda"
%
complement
Java Interaction
This page provides examples for the following functions.
memfn
proxy
into-array
double-array
genclass
Namespaces
ns
(ns test.test
(:refer-clojure :exclude [+ -]))
(defn +
[a b]
33)
(+ 1 2) ;= 33
require
(require '[clojure.zip :as zip])
(require ['clojure.contrib.sql :as 'sql])
Misc.
test
user=> (defn
#^{:test (fn []
(assert (= 4 (myadd 2 2))))}
myadd [a b]
(+ a b))
#'user/myadd
user=> (test #'myadd)
:ok