Skip to content

Instantly share code, notes, and snippets.

@curtosis
Created July 29, 2015 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curtosis/06c415f03115de06e676 to your computer and use it in GitHub Desktop.
Save curtosis/06c415f03115de06e676 to your computer and use it in GitHub Desktop.
nested filtered map
(defn unsaturated-diffs [cuis diffs-by-parent]
(let [cuiset (set cuis)
cui-in-note? (fn [cui]
(contains? cuiset (:cui_id cui)))
some-fully-saturated-diff (fn [diffs]
(some
(fn [[_ grouped-diffs]]
(every? cui-in-note? grouped-diffs))
(group-by :diff__code diffs)))]
(reduce-kv (fn [m k v]
(if-not (some-fully-saturated-diff v)
(assoc m k v)
m))
{}
diffs-by-parent)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment