object PutFunctionToCollection { def main(args:Array[String]): Unit ={ val name = List("Peter","Paul","Mary") name.map(_.toUpperCase) def ulcase(s:String) = Vector(s.toUpperCase(),s.toLowerCase()) name.map(ulcase).foreach(System.out.println(_)) }}
List(1,7,2,9).reduceLeft(_-_) //((1-7)-2)-9 = -17
scala 将函数映射到集合
最新推荐文章于 2022-10-24 13:47:42 发布