Last modified on 5 July 2010, at 06:52

Clojure Programming/Examples/API Examples/Variable Definition

defEdit

user=> (def x 4) 
#'user/x
user=> x
4
user=> (def y '(\a :b "c"))
#'user/y
user=> y
(\a :b "c")
user=> (def z (fn[] 3))
#'user/z
user=> (z)
3

bindingEdit

user=> (def x 1)
#'user/x
user=> (def y 2)
#'user/y
user=> (def get-x-y (fn [] (list x y)))
#'user/get-x-y
user=> (get-x-y)
(1 2)
user=> (binding [x 100 y 200] (get-x-y))
(100 200)
user=> (get-x-y)
(1 2)