On 2010 Apr 15, at 11:53 PM, Derek wrote:
(defn foo [map1 map2] (map (fn [k v] (map2 k)) map1))
(foo {:a 1 :b 2} {:a 5 :b 6 :c 7})
When you turn a map into a sequence, you get a sequence of two-element
sequences(1),
so if you change your anonymous function to destructure that, it will
work:
user=> (defn foo [map1 map2] (map (fn [[k v]] (map2 k)) map1))
#'user/foo
user=> (foo {:a 1 :b 2} {:a 5 :b 6 :c 7})
(5 6)
--Doug
(1) http://clojure.org/data_structures says:
... seq returns a sequence of map entries, which are key/value
pairs. ...
I haven't yet found where in the docs a pair is defined, so I am
guessing that the concrete type (list, vector,...) for a pair is not
relevant/important.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en