See also ComposeFunction
An operation on functions, usually denoted by a middot, a circle or juxtaposition. In the following, let us denote composition by a lowercase 'o'.
(f o g)(x) = f(g(x))
, we have the predefined function "." which is composition:
f . g = \x -> f (g x)
Composition can be used extensively to build processing lines out of individual building blocks. You often see code as the following in Haskell:
nextmoves breadth = pruneBadMoves breadth . pruneImpossible . genNextMoves
pruneBadMoves breadth = pruneByValue breadth . estimateMove . pruneByDepth 3
Some people define InverseFunctionalComposition
to avoid these read-last-to-first definitions, e.g.
f >>> g = \x -> g (f x) -- in Haskell's Control.Category
...and some people use ForthLanguage or JoyLanguage instead.
, we have the predefined operator "o" which is composition
shows that you can do almost everything with just composition of well-chosen primitives.
View edit of May 16, 2011
or FindPage with title or text search