Skip to content

Instantly share code, notes, and snippets.

@davidallsopp
Created September 29, 2013 11:25
Show Gist options
  • Save davidallsopp/6751633 to your computer and use it in GitHub Desktop.
Save davidallsopp/6751633 to your computer and use it in GitHub Desktop.
Letter frequency one-liner in Scala.
"zoology".groupBy(identity).mapValues(_.length)
// Map(y -> 1, g -> 1, l -> 1, o -> 3, z -> 1)
// identity is equivalent to x => x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment