Skip to content

Instantly share code, notes, and snippets.

@gfredericks
Created June 18, 2010 19:46
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 gfredericks/444111 to your computer and use it in GitHub Desktop.
Save gfredericks/444111 to your computer and use it in GitHub Desktop.
;;
;; Not having used clojure with more than one person, I'm curious if code like this
;; would generally be considered too dense/unclear
;;
(defn changes
"Takes two maps and returns a map of the differences"
[suspense-data master-data]
(let [sd (set suspense-data), md (set master-data)
keyz (distinct (map first (clojure.set/difference
sd
(clojure.set/intersection md sd))))]
(apply hash-map (reduce concat
(map (fn [k] [k {:old (k master-data) :new (k suspense-data)}]) keyz)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment