Created
November 13, 2013 20:37
-
-
Save sharathprabhal/7455974 to your computer and use it in GitHub Desktop.
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 getCounts[T](list: Seq[T]): Map[T, Int] = { | |
list.foldLeft(Map.empty[T, Int]) { (m: Map[T, Int], x: T) => m + ((x, m.getOrElse(x, 0) + 1)) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment