libb.compose
- compose(*functions)[source]
Return a function folding over a list of functions.
Each arg must have a single param.
- Parameters:
functions – Functions to compose.
- Returns:
Composed function.
Example:
>>> f = lambda x: x+4 >>> g = lambda y: y/2 >>> h = lambda z: z*3 >>> fgh = compose(f, g, h)
Beware of order for non-commutative functions (first in, last out):
>>> fgh(2)==h(g(f(2))) False >>> fgh(2)==f(g(h(2))) True