Clojure Programming/Examples/API Examples
From Wikibooks, open books for an open world
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
Contents |
[edit] Documentation
This page provides examples for the following functions.
[edit] Data Structures
[edit] Numbers
| Computation | + | - | * | / | inc | dec | min | max | rem | rationalize |
|---|---|---|---|---|---|---|---|---|---|---|
| Comparison | == | < | > | <= | >= | |||||
| Predicates | zero? | pos? | neg? |
[edit] Strings
[edit] Characters
[edit] Advanced Data Structures
[edit] Lists
[edit] Vectors
[edit] Maps
[edit] Struct Maps
[edit] Array Maps
[edit] Sets
[edit] Zippers
[edit] Sequences
[edit] Sequence Building
[edit] Mapping Operators
This page provides examples for the following functions.
[edit] Macros
[edit] do Macros
This page provides examples for the following functions.
[edit] Variable Definition
This page provides examples for the following functions.
[edit] MultiMethod
This page defines the following functions
[edit] Reference Tools
This page defines the following functions.
[edit] Predicate functions
This page provides examples for the following functions.
[edit] Recursion Tools
This page defines the following functions.
[edit] Function Tools
This page provides examples for the following functions.
[edit] Java Interaction
This page provides examples for the following functions.
[edit] Namespaces
[edit] ns
(ns test.test
(:refer-clojure :exclude [+ -]))
(defn +
[a b]
33)
(+ 1 2) ;= 33
[edit] require
(require '[clojure.zip :as zip])
(require ['clojure.contrib.sql :as 'sql])
[edit] Misc.
[edit] test
user=> (defn
#^{:test (fn []
(assert (= 4 (myadd 2 2))))}
myadd [a b]
(+ a b))
#'user/myadd
user=> (test #'myadd)
:ok