Thank you Gary.
There's no reason why this need to be a macro.
It has rewritten as a function.
And I'd still like to hear any response about the same three questions.
(require '[clojure.test :refer (with-test is run-tests)])
(with-test
(defn mapf [f m & args]
((fn g [n]
(if (map? n)
(into {} (map (fn [[k v]] [k (g v)]) n))
(apply f n args)))
m))
(is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})
{:a {:b 9 :c 16} :d 25}))
(is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)
{:a {:b 10 :c 17} :d 26})))
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.