Reputation: 25842
let (++) f g x = f (g x) in
let f x = x + 1 in
let g x = x * 2 in
(f++g) 1;;
f++g x = 2 * x + 1
. Am I correct?Upvotes: 4
Views: 452
Reputation: 6195
Your implementation of function composition is correct, since :
(g ∘ f)(x) = g(f(x)) for all x in X
according to wikipedia
I get :
- : int = 3
in ocamlktop
Upvotes: 4