Last active
March 20, 2019 17:35
-
-
Save neilchaudhuri/fb288ef2b338930408fe300989ad3c0c to your computer and use it in GitHub Desktop.
Example of idiomatic Scala for counting words in a collection
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
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