You're viewing version 1.2.0 of eval. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16
  • (eval form)
Evaluates the form data structure (not text!) and returns the result.

2 Examples top

  • user=> (def *foo* "(println [1 2 3])")
    #'user/*foo*
    
    user=> *foo*
    "(println [1 2 3])"
    
    user=> (eval *foo*)   ; Notice eval'ing a string does not work.
    "(println [1 2 3])"
    
    user=> (eval (read-string *foo*))
    [1 2 3]
    nil
  • user=> (eval '(let [a 10] (+ 3 4 a)))
    17
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2379 top

(defn eval
  "Evaluates the form data structure (not text!) and returns the result."
  {:added "1.0"}
  [form] (. clojure.lang.Compiler (eval form)))
Vars in clojure.core/eval: defn

Comments top

1 comment(s) for eval.

In normal code, eval is rarely used.

Log in to add a comment.