dic = {k: v for k, v in dic.items() if k in other_dic and v == "bar"}
> "How could that be improved? That's 3-4 LOC minimum in any other language"If I'm understanding the comprehension correctly,
(into {} (filter (fn [[k v]] (and (get other-dic k) (= v "bar"))) dic))
Though, for readability, I'd likely write it as: (->> dic
(filter (fn [[k v]]
(and (get other-dic k)
(= v "bar"))))
(into {}))
Legibility is in the eye of the beholder.