f is a functional value I know. It accepts String as its argument for now.
Can f accepts another functional value as its argument? if so how to write?
(I tried to write it which doesn’t work).
It’s pretty sure. The function is the first class value, so it can be used where a value can used. The following is a sample to encode the succ function of Church’s Numerals:
val succ1 = (n: (Int=>Int)=>Int=>Int)=>(s:Int=>Int)=>(z:Int)=>s(n(s)(z))
def succ2(n: (Int=>Int)=>Int=>Int)(s:Int=>Int)(z:Int): Int = s(n(s)(z))