object HelloWorld { def main(args: Array[String]) { val l = List(5,1,2,7,3) def insert:(List[Int],Int)=>List[Int]= (ls,v)=>ls match { case a::b =>{ if(a>v) List(v):::List(a):::b else List(a)::: insert(b,v) } case _ => List(v) } def zwei:Int=>Int= x=>x*2 val ls=List(1,2,3) println(ls.map(x=>zwei(x))) println(ls.map(zwei(_))) println(ls.map(zwei)) def sort:List[Int]=>List[Int]= x=>x.foldRight(List[Int]())((x,y)=>insert(y,x)) def sort2:List[Int]=>List[Int]= x=>x.foldLeft(List[Int]())((a,b)=>insert(a,b)) } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more