Also the function
(defn foo [map1 map2] (map map2 (keys map1)))
seems to be a bit more clear.
Peter
--
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 m
Thank you all for the explanations. I see now that I wasn't paying
close enough attention, and needed to add another pair of brackets to
destructure my lambda's single argument.
On Apr 16, 11:51 am, Per Vognsen wrote:
> Tangent:
>
> On Fri, Apr 16, 2010 at 7:41 PM, Douglas Philips wrote:
> > (1)
Tangent:
On Fri, Apr 16, 2010 at 7:41 PM, Douglas Philips wrote:
> (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,
The function you give to map needs to accept the same number of args
as there are collections. You're passing one map, thus the function
will be called with one arg. In the case of maps the "element" is a
key/value pair, which can then be destructured in the function.
On Apr 15, 8:53 pm, Derek w
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
I feel like I'm probably doing something dumb, but here's my problem.
Below is a function that could take two maps, and return a list of all
the values in the second map for each key of the first:
(defn foo [map1 map2] (map (fn [k v] (map2 k)) map1))
(foo {:a 1 :b 2} {:a 5 :b 6 :c 7})
I would exp