How to filter a persistent map in Clojure?

Posted by Checkers on Stack Overflow See other posts from Stack Overflow or by Checkers
Published on 2010-05-02T15:08:51Z Indexed on 2010/05/02 15:18 UTC
Read the original article Hit count: 138

Filed under:

I have a persistent map which I want to filter. Something like this:

(filter #(-> % val (= 1)) {:a 1 :b 1 :c 2})

The above comes out as ([:a 1] [:b 1]) (a lazy sequence of map entries). However I want to be get {:a 1 :b 1}.

How can I filter a map so it remains a map without having to rebuild it from a sequence of map entries?

© Stack Overflow or respective owner

Related posts about clojure