1.集合操作练习
//创建一个List
val lst0 = List(1,7,9,8,0,3,5,4,6,2)
//将lst0中每个元素乘以10后生成一个新的集合
lst0.map(x => x*10...) OR lst0.map(_*10 )
//将lst0中的偶数取出来生成一个新的集合
lst0.filter(x => x%2==0)
lst0.filter(x => x%2==0).map(_...先按空格切分,在压平
scala> lines.map(_.split(" "))
res9: List[Array[String]] = List(Array(hello, tom, hello, jerry...> a.par.fold(10)(_ + _)
res28: Int = 51
//折叠:有初始值(有特定顺序)
//foldLeft()(_ + _)
//foldRight()(_ + _)...> res29.mapValues(_.foldLeft(0)(_ + _._2))
res31: scala.collection.immutable.Map[String,Int] = Map(tom