-
-
Save anonymous/ee3cfb4934510563253a 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
(def pairs [(8 2) (2 4) (3 9) (27 3) (9 3)]) | |
(reduce (fn [currMap [a b]] | |
(let [match (first (filter (fn [group] (some #(or (= % a) (= % b) group))) currMap))] | |
(if match | |
(replace {match: (into match [a b])} currMap) | |
(into currMap [a b])))) | |
{} | |
pairs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment