Skip to content

Instantly share code, notes, and snippets.

@lnostdal
Created April 9, 2018 15:41
Show Gist options
  • Save lnostdal/5d023c0173e23961dbd4c3e13ce06b3f to your computer and use it in GitHub Desktop.
Save lnostdal/5d023c0173e23961dbd4c3e13ce06b3f to your computer and use it in GitHub Desktop.
Clojure: guava HashBiMap + MapDifference
quantataraxia.core> (let [m1 (HashBiMap/create {1 :a 2 :b 3 :c})
m2 (HashMap. {:a 1 :b 2})
m1inv (.inverse m1)]
(with (Maps/difference m1inv m2)
(.removeAll (.keySet m1inv) (.keySet (.entriesOnlyOnLeft it)))
(pprint (into {} m1))
(pprint (into {} m1inv))))
{1 :a, 2 :b}
{:a 1, :b 2}
;; maybe someone will find this snippet useful --- https://Quanto.ga/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment