Skip to content

Instantly share code, notes, and snippets.

@tommyettinger
Forked from dagda1/diff.clj
Last active August 29, 2015 14:06
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 tommyettinger/1aa331ebf9beae79fb6f to your computer and use it in GitHub Desktop.
Save tommyettinger/1aa331ebf9beae79fb6f to your computer and use it in GitHub Desktop.
(defn diff [l1 l2]
(let [a (group-by identity l1)
b (group-by identity l2)]
(mapcat #(repeat
(-
(count (second %))
(count (get b (key %))))
(key %))
a)))
(defn diff-unordered [l1 l2]
(let [a (group-by identity l1)
b (group-by identity l2)]
(mapcat #(repeat
(Math/abs (-
(count (second %))
(count (get b (key %)))))
(key %))
a)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment