Clojure Programming/Examples/API Examples
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
editThis page provides examples for the following functions.
Data Structures
editNumbers
editComputation | + | - | * | / | inc | dec | min | max | rem | rationalize |
---|---|---|---|---|---|---|---|---|---|---|
Comparison | == | < | > | <= | >= | |||||
Predicates | zero? | pos? | neg? |
Strings
editCharacters
editAdvanced Data Structures
editLists
editVectors
editMaps
editStruct Maps
editArray Maps
editSets
editZippers
editSequences
editSequence Building
editMapping Operators
editThis page provides examples for the following functions.
Macros
editdo Macros
editThis page provides examples for the following functions.
Variable Definition
editThis page provides examples for the following functions.
MultiMethod
editThis page defines the following functions
Reference Tools
editThis page defines the following functions.
Predicate functions
editThis page provides examples for the following functions.
Recursion Tools
editThis page defines the following functions.
Function Tools
editThis page provides examples for the following functions.
Java Interaction
editThis page provides examples for the following functions.
Namespaces
editns
edit(ns test.test
(:refer-clojure :exclude [+ -]))
(defn +
[a b]
33)
(+ 1 2) ;= 33
require
edit(require '[clojure.zip :as zip])
(require ['clojure.contrib.sql :as 'sql])
Misc.
edittest
edituser=> (defn
#^{:test (fn []
(assert (= 4 (myadd 2 2))))}
myadd [a b]
(+ a b))
#'user/myadd
user=> (test #'myadd)
:ok