I am reading this tutorial on Haskell. They define function composition as the following:
(.) :: (b->c) -> (a->b) -> (a-
The composition of f
and g
is a function that first applies g
to its argument, then f
to the value returned by g
. It then returns the return value of f
.
This identity may be enlightening:
f (g x) = (f . g) x
If you have a Java/C background, consider this example:
int f(int x);
int g(int x);
int theComposition(int x) { return f(g(x)); }