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

edit

This page provides examples for the following functions.

Data Structures

edit

Numbers

edit
Computation + - * / inc dec min max rem rationalize
Comparison == < > <= >=
Predicates zero? pos? neg?

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

edit

This page provides examples for the following functions.

Macros

edit

do Macros

edit

This page provides examples for the following functions.

Variable Definition

edit

This page provides examples for the following functions.

MultiMethod

edit

This page defines the following functions

Reference Tools

edit

This page defines the following functions.

Predicate functions

edit

This page provides examples for the following functions.

Recursion Tools

edit

This page defines the following functions.

Function Tools

edit

This page provides examples for the following functions.

Java Interaction

edit

This page provides examples for the following functions.

Namespaces

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.

edit

test

edit
user=> (defn
  #^{:test (fn []
    (assert (= 4 (myadd 2 2))))}
  myadd [a b]
  (+ a b))
#'user/myadd
user=> (test #'myadd)
:ok