Skip to content

Instantly share code, notes, and snippets.

@mesagie
Created March 10, 2013 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mesagie/5128389 to your computer and use it in GitHub Desktop.
Save mesagie/5128389 to your computer and use it in GitHub Desktop.
Counting occurrences one-liner
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