Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def counter(file: String) = scala.io.Source.fromFile(file)
- .getLines
- .flatMap(_.split("\\W+"))
- .foldLeft(Map.empty[String, Int]){
- (count, word) => count + (word -> (count.getOrElse(word, 0) + 1))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement