def twice1(func: Int=>Int)= (i:Int) => func(func(i)); val add2 = (a:Int) => a + 2; val add4 = twice1(add2); println( add4(5)); def twice2[T](func: T=>T)= (t:T) => func(func(t)); val appendMark = (a:String) => a + "!"; println( twice2(appendMark)("Hello"));
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment