Reputation: 131
Consider the following:
list of hashmaps '({:key 1 :other-key "hello"} {:key 2 :other-key "bye"})
some list of keys: '(1)
;; I want the result to be:
[{:key 1 :other-key "hello"}]
Is there a simple way to filter this out?
Upvotes: 0
Views: 137
Reputation: 34870
You could do it like this:
(def l1 '({:key 1, :other-key "hello"} {:key 2, :other-key "bye"}))
(def l2 '(1))
(filter #(contains? (set l2) (:key %)) l1)
Upvotes: 2
Reputation: 131
Ended up doing something like this:
(filter #(some #{(:key %)} some-list) list-of-hashmaps)
Upvotes: 1