Conte palavras em uma string em Scala

def countWords(text: String) = text.split(” “).map(_.toLowerCase).groupBy(identity).mapValues(_.size) Uso: scala> countWords(“What I would do to see what you would do when I see what everybody would do”)res8: scala.collection.immutable.Map[String,Int] = Map(what -> 3, …

Continuar lendo