ショック!ワードカウントを達成するためのScala 1行のコード!!!

import scala.io.Source
object wordcount1 {
    
    
  def main(args: Array[String]): Unit = {
    
    
    Source.fromFile("D:\\Big_Data\\myscala\\data\\words.txt").getLines().flatMap(_.split(",")).map((_, 1)).toList.groupBy(_._1).map(x => (x._1, x._2.map(_._2).sum)).foreach(println)
  }
}

おすすめ

転載: blog.csdn.net/qq_45750230/article/details/107855742