Re: Get multiple vals from a map

2011-12-07 Thread vitalyper
Thanks, Alan. It is more general solution which also works for keys that are not keywords user=> (map {"a" 1 "b" 2 "c" 3} [ "a" "b"]) (1 2) On Dec 1, 5:02 pm, Alan Malloy wrote: > I usually use juxt, but a more correct/robust solution is to use map, > with the lookup-map as the function: > > (map

Re: Get multiple vals from a map

2011-12-01 Thread Alan Malloy
I usually use juxt, but a more correct/robust solution is to use map, with the lookup-map as the function: (map {:foo 1 :bar 2 :baz 0} [:foo :bar]) On Dec 1, 12:26 pm, Ulises wrote: > How about using juxt: > > sandbox> ((juxt :foo :bar) {:foo 1 :bar 2 :baz 0}) > [1 2] > sandbox> > > This only wo

Re: Get multiple vals from a map

2011-12-01 Thread vitalyper
Thanks, works in my case. On Dec 1, 3:26 pm, Ulises wrote: > How about using juxt: > > sandbox> ((juxt :foo :bar) {:foo 1 :bar 2 :baz 0}) > [1 2] > sandbox> > > This only works, however, if you use keywords for keys (as they are > functions themselves). > > U -- You received this message becaus

Re: Get multiple vals from a map

2011-12-01 Thread joegallo
((juxt :foo :bar) {:foo 1 :bar 2 :baz 3}) juxt to the rescue -- 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

Re: Get multiple vals from a map

2011-12-01 Thread Ulises
How about using juxt: sandbox> ((juxt :foo :bar) {:foo 1 :bar 2 :baz 0}) [1 2] sandbox> This only works, however, if you use keywords for keys (as they are functions themselves). U -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gro

Get multiple vals from a map

2011-12-01 Thread vitalyper
Is there something build in for getting multiple vals out of the map? {:keys [...]} woks in destructuring forms. It is quite easy to build something with filter and map but I suspect these is a common problem somebody solved already. Desired (get-vals [:a :b] {:a 1 :b 2 :c 3}) (1 2) -- You receiv