Clojure 编程/示例/API 示例/变量定义
外观
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
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)