Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. def counter(file: String) = scala.io.Source.fromFile(file)
  2. .getLines
  3. .flatMap(_.split("\\W+"))
  4. .foldLeft(Map.empty[String, Int]){
  5. (count, word) => count + (word -> (count.getOrElse(word, 0) + 1))
  6. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement