Created
September 30, 2014 18:49
-
-
Save nelanka/7c8d563a581bd87c95b2 to your computer and use it in GitHub Desktop.
Merge Maps
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 mergeMaps[A, B](map1: Map[A, Set[B]], map2: Map[A, Set[B]]): Map[A, Set[B]] = { | |
(map1.toSeq ++ map2.toSeq).groupBy(_._1).mapValues(_.map(_._2).toSet).mapValues(_.flatten) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment