Make A Function That Can Be Piped¤
stamox.core.pipe.make_pipe(func: Optional[Callable[..., ~T]] = None, name: str = None) -> Callable[..., ~T]
¤
Makes a Function Pipeable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable |
Function or Callable Class. |
None |
name |
str |
Name of the Function. Defaults to "PipeableFunc". |
None |
kwargs |
optional |
Additional keyword arguments. |
required |
Returns:
Type | Description |
---|---|
Callable |
The wrapped function. |
Examples:
>>> from stamox import make_pipe
>>> @make_pipe
... def add(x):
... return x + 1
>>> h = add >> add >> add
>>> h(1)
4
stamox.core.pipe.make_partial_pipe(func: Optional[Callable[..., ~T]] = None, name: str = None) -> Callable[..., ~T]
¤
Makes a Partial Function Pipe.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable |
Function or Callable Class. |
None |
name |
str |
Name of the Function. Defaults to "PipeableFunc". |
None |
kwargs |
dict |
Keyword arguments for the function. |
required |
Returns:
Type | Description |
---|---|
Callable |
A partial function pipe. |
Examples:
>>> from stamox import make_partial_pipe
>>> @make_partial_pipe
... def add(x, y):
... return x + y
>>> h = add(y=1) >> add(y=2) >> add(y=3)
>>> h(1)
7