object ZipDemo{
def main(args:Array[String]):Unit={
val arr:Array[String]=Array("wnn","lcc","hxx")
val arr1:Array[Int]=Array(1,2,3)
val res:Array[(String,Int)]= arr.zip(arr1)//第一种方式
res.foreach(println)//第二种方式
val mp:Map[String,Int]=res.toMap
for(elem<-mp){println(elem)}}}
val res1:Map[(String,Int),Int]=mp.zip(List(1,2,3,4))
val res1:Map[(String,Int),Int]=mp.zip(1tomp.size)for(elem<-res1){println(elem)}
val res:Array[((String,Int),Int)]=arr.zip(arr1).zipWithIndex
res.foreach(println)
val res1:Map[((String,Int),Int),Int]= res.toMap.zipWithIndex
object ReduceDemo{
def main(args:Array[String]):Unit={
val ls=List(1,2,3,4,5,6)
val res= ls.reduce(_+_)println(res)}}
object ReduceDemo{
def add(x:Int)={(a:Int,b:Int)=>a+b
}
def main(args:Array[String]):Unit={
val c:Int=add(20)(30,4)println(c)
val ls=List(1,2,3,4,5,6)
val res= ls.reduce(_+_)
val res1:Int=ls.fold(100)(_ + _)println(res1)}}
val arr=List("wnn","lcc","hxx")
val res2:String=arr.reduce(_+" -"+_)println(res2)