Programmatically evaluate a list of functions in Clojure -
i trying figure out how programmatically evaluate list of functions.
lets have code:
(defn foo [] (println "foo")) (defn bar [] (println "bar")) (def funcs [foo bar] ) i want execute functions of funcs in programmatically way.
i tried use eval, no succcess.
thanks help.
use for if want return values, , ok lazy evaluation (your functions not guaranteed called until access return value), , doseq if don't need values , doing immediate side effects.
(doseq [f [foo bar]] (f)) (def fs (for [f [foo bar]] (f)))