< Clojure Programming < 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

This page provides examples for the following functions.

Data Structures

Numbers

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

Strings

Characters

Advanced Data Structures

Lists

Vectors

Maps

Struct Maps

Array Maps

Sets

Zippers

Sequences

Sequence Building

Mapping Operators

This page provides examples for the following functions.

Macros

do Macros

This page provides examples for the following functions.

Variable Definition

This page provides examples for the following functions.

MultiMethod

This page defines the following functions

Reference Tools

This page defines the following functions.

Predicate functions

This page provides examples for the following functions.

Recursion Tools

This page defines the following functions.

Function Tools

This page provides examples for the following functions.

Java Interaction

This page provides examples for the following functions.

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
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.