• (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:2791 top

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

Comments top

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