Created
June 18, 2010 19:46
-
-
Save gfredericks/444111 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; | |
;; 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