let (++) f g x = f (g x) in
let f x = x + 1 in
let g x = x * 2 in
(f++g) 1;;
- Is the above expression correct?
- It seems to me that the above code should be just like defining
f++g x = 2 * x + 1
. Am I correct?
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?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