Hello Parth,
(defn print-decorate [f] (fn [& args] (println (:name (meta (var f))) "called with" args) (apply f args)))
f is not a toplevel binding, but only a local variable. This is the issue here,
I think. Please try the following.
(defn print-decorate [f]
(fn [& args]
(println (:name (meta f)) "called with" args)
(apply (var-get f) args)))
This has to be called with the Var not the function itself. It gives me: ---8<--- foo=> (defn bar [x] x) #'foo/bar user=> (foo/bar 5) 5 user=> (def bar (print-decorate #'foo/bar)) #'user/bar user=> (bar 5) bar called with (5) 5 ---8<--- Please note also the namespace change in between! :) Sincerely Meikel
smime.p7s
Description: S/MIME cryptographic signature
