Standard ML of New Jersey (32-bit) v110.99 [built: Thu Dec 24 11:01:10 2020] - - fun f x h = h x; val f = fn : 'a -> ('a -> 'b) -> 'b - - - f 5 (fn x => x*x); val it = 25 : int - - f 7 (fn x => x*x); val it = 49 : int - - f 7 (fn x => x*x*x); val it = 343 : int - - f "cat" (fn s => s ^ s); val it = "catcat" : string - - f 5 (fn x => 1.0 + real x); val it = 6.0 : real - - f 5.0 (fn x => 1.0 + real x); stdIn:13.1-13.29 Error: operator and operand do not agree [tycon mismatch] operator domain: real -> 'Z operand: int -> real in expression: (f 5.0) (fn x => 1.0 + real x) - - - fun f g h x = g (h x); val f = fn : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b - - f (fn x => x*x) (fn x => 2 + x) 3; val it = 25 : int - - - f (fn s => String.size s) (fn s => s ^ s) "cat"; [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable] [autoloading done] val it = 6 : int - - f (fn s => String.size s) (fn s => s ^ s) "cats"; val it = 8 : int -