4 Examples top

  • user=> (def my-val 5)
    #'user/my-val
    user=> my-val
    5
  • user=> (def my-function (fn [x] (* x x x)))
    #'user/my-function
    user=> (my-function 4)
    64
  • ;; This is an example of setting a docstring during a def in 
    ;; Clojure 1.2.  In 1.3, def takes an optional docstring directly.
    
    user> (def ^{:doc "The nuge rocks"} ted-nugent)
    #'user/ted-nugent
    user> (doc ted-nugent)
    -------------------------
    user/ted-nugent
    nil
      The nuge rocks
  • ;; give function another name
    user=> (def sys-map map)
    ;; give macro another name
    user=> (def #^{:macro true} sys-loop #'loop)
Log in to add / edit an example.

See Also top

Log in to add a see also.

Comments top

No comments for def. Log in to add a comment.