Created
April 9, 2018 15:41
-
-
Save lnostdal/5d023c0173e23961dbd4c3e13ce06b3f to your computer and use it in GitHub Desktop.
Clojure: guava HashBiMap + MapDifference
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
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