Created
January 7, 2015 10:17
-
-
Save haiy/4144a27441c2db858d2f to your computer and use it in GitHub Desktop.
scala map merge
This file contains hidden or 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 merge(m1: Map[String, Int], m2: Map[String, Int]): Map[String, Int] = | |
m1 ++ m2.map { case (k, v) => k -> (v + m1.getOrElse(k, 0)) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment