4ZM
4ZM

Reputation: 1503

How to filter on specific key values in clojure?

What is an idiomatic way to get the maps with a specific value for a particular key in a Clojure seq?

E.g. get the maps in a seq :tag-ed with :fubar value.

(filter #(= (% :tag) :fubar) some-seq)

This works, but I'm guessing there is some more elegant way to do it...

Upvotes: 4

Views: 763

Answers (1)

Leon Grapenthin
Leon Grapenthin

Reputation: 9266

(filter (comp #{:fubar} :tag) some-seq) 

Upvotes: 4

Related Questions