Last active
May 3, 2018 06:06
-
-
Save visibletrap/3ce4cc7d033153b0724558a714922082 to your computer and use it in GitHub Desktop.
Given input: {1 [:a :b], 2 [:a], 3 [:b], 4 [:b :c], 5 [:a], 6 [:a :c :e]}. Expected output: {:a [1 2 5 6], :b [1 3 4], :c [4 6], :e [6]}
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
(->> {1 [:a :b], 2 [:a], 3 [:b], 4 [:b :c], 5 [:a], 6 [:a :c :e]} | |
(map (fn [[k v]] (zipmap v (repeat [k])))) | |
(apply merge-with into)) | |
;=> {:a [1 2 5 6], :b [1 3 4], :c [4 6], :e [6]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment