Skip to content

Instantly share code, notes, and snippets.

@neilchaudhuri
Last active March 20, 2019 17:35
Show Gist options
  • Save neilchaudhuri/fb288ef2b338930408fe300989ad3c0c to your computer and use it in GitHub Desktop.
Save neilchaudhuri/fb288ef2b338930408fe300989ad3c0c to your computer and use it in GitHub Desktop.
Example of idiomatic Scala for counting words in a collection
val words = List("Fear", "of", "a", "name", "only", "increases", "fear", "of", "the", "thing", "itself")
words
.groupBy(_.toLowerCase)
.mapValues(_.size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment