Pipeline
Apply arbitrary number of functions to instance
in succession.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance
|
Any
|
Scalar object. |
required |
*functions
|
Callable
|
Functions. |
()
|
Returns:
Type | Description |
---|---|
Any
|
Result of applying all function(s) to |
Examples:
>>> # works with unary function
>>> add_two = lambda x: x + 2
>>>
>>> # works with partial functions
>>> add_n = lambda x, n: x + n
>>>
>>> # works with closures
>>> def add_n(n: int) -> Callable:
>>> def closure(x):
>>> return x + n
>>> return closure
>>>
>>> result = pipe(12, add_two, add_n(10), add_n(-4))
>>> assert result == 20