An idea with many names.
given two functions f and g,
such that the range of g is a subset
of the domain of f, the composition
of f and g is a new function
h such that h(x) =
The symbol for composition
of f and
g is g∘f
(sometimes ASCIIfied as gof).
Category theorists sometimes write
f;g (note order is
swapped) to denote the same thing.
In a programming language, composition may be
written as a higher-order function (eg, in Scheme below):
(define (compose f g) (lambda (x) (f (g x))))
In a polymorphic language, the above definition would
have type ((b -> c) * (a -> b)) -> a -> c,
or in curried form
(b -> c) -> (a -> b) -> a -> c.
As a final note, function composition is also
known as the B combinator in some circles. It is
defined by the rewrite rule
Bfgx => f(gx)
or in terms of the S and K
combinators B = S(KS)K