Guest User

Untitled

a guest
Aug 14th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. Clojure: how to evaluate a quoted form in the local scope?
  2. (equal-chance
  3. (println "1")
  4. (println "2"))
  5.  
  6. (defmacro equal-chance
  7. [& exprs]
  8. `(rand-nth '~exprs))
  9.  
  10. (let [x 10] (eval '(println x)))
  11.  
  12. (defmacro equal-chance [& exprs]
  13. `((rand-nth [~@(map (fn [e] `(fn [] ~e)) exprs)])))
  14.  
  15. (defmacro equal-chance
  16. [& exprs]
  17. (rand-nth exprs))
Add Comment
Please, Sign In to add comment