- Mattox
------------------------------------------------
- : int = 32
# let (+) a b = a - b;;
val ( + ) : int -> int -> int = <fun>
# 20 + 30;;
- : int = -10
# let plus x y = x + y;;
val plus : int -> int -> int = <fun>
# let inc = plus 1;;
val inc : int -> int = <fun>
# inc 10;;
- : int = -9
#
mattox@curry:~/today/cs440$ ocaml
Objective Caml version 3.09.1
# let plus x y = x + y;;
val plus : int -> int -> int = <fun>
# let inc = plus 1;;
val inc : int -> int = <fun>
# inc 10;;
- : int = 11
# let x = 20;;
val x : int = 20
# inc 10;;
- : int = 11
# let plus = fun x -> fun y -> x + y;;
val plus : int -> int -> int = <fun>
# let foo x y = x + y;;
val foo : int -> int -> int = <fun>
# let bar (x,y) = x + y;;
val bar : int * int -> int = <fun>
# foo 3;;
- : int -> int = <fun>
# (* foo : ('a * 'b -> 'c) -> 'a -> 'b -> 'c *)
let foo f x y = f (x,y);;
val foo : ('a * 'b -> 'c) -> 'a -> 'b -> 'c = <fun>
# let inc = foo bar 1;;
val inc : int -> int = <fun>
# inc 30;;
- : int = 31