scala 将函数映射到集合

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

猜你喜欢

转载自blog.csdn.net/seaReal1/article/details/80088747