aspis.common.compose

aspis.common.compose(*funcs)[source]

Performs right-to-left function composition. The last argument may have any arity; the remaining arguments must be unary.

See also pipe

Parameters:

*funcs (Callable[[T], T]) – List of functions to be composed.

Returns:

Right-to-left composed function.

Return type:

Callable

Examples

>>> times_two = multiply(2)
>>> add_two = add(2)
>>> multiply_then_add = compose(add_two, times_two)
>>> result = multiply_then_add(3)  # returns 8