clojure - Intersecting a list of lists of maps overriding equality -
i have list of lists of maps:
(( {:id 1 :temp 1} {:id 2} ) ( {:id 1 :temp 2} ) ( {:id 1 :temp 3} {:id 2} ))
i want ids @ intersection of these 3 sets :id
key. result here 1
i came solution it's hurting eyes:
(def coll '(( {:id 1 :temp 1} {:id 2} ) ( {:id 1 :temp 2} ) ( {:id 1 :temp 3} {:id 2} ))) (apply clojure.set/intersection (map set (map (fn [m] (map #(select-keys % '(:id)) m)) coll)))
returns
#{{:id 1}}
which ok, other suggestions?
if fine getting #{1}
(as mention initially) instead of #{{:id 1}}
, can improved:
(apply set/intersection (map (fn [c] (into #{} (map :id c))) coll))
Comments
Post a Comment