Created
March 10, 2013 12:31
-
-
Save mesagie/5128389 to your computer and use it in GitHub Desktop.
Counting occurrences one-liner
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
scala> "encyclopedia" groupBy identity mapValues (_.size) | |
res2: scala.collection.immutable.Map[Char,Int] = Map(e -> 2, n -> 1, y -> 1, a -> 1, i -> 1, l -> 1, p -> 1, c -> 2, o -> 1, d -> 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment