Functional Utilities Library This is a Python library that provides functional utilities for writing functional-style code in Python. The library includes the following utilities:
Pipe class The Pipe class is a generic class that allows you to create a pipeline of functions that transform an input to an output. You can use the Pipe class to chain together multiple functions and apply them to an input value in a single expression. Here's an example:
from functional_utils import Pipe
def add_one(x):
return x + 1
def double(x):
return x * 2
result = Pipe(add_one) >> double >> double >> add_one(3)
print(result) # Output: 23
In this example, we create a Pipe object that applies the add_one function, then the double function twice, and finally the add_one function again to an input value of 3. The output of the pipeline is 23.
pattern_match function The pattern_match function allows you to apply a transformer function based on the first predicate that matches the input value. You can use the pattern_match function to write code that selects a specific branch of execution based on the input value. Here's an example:
from functional_utils import pattern_match
def is_even(x):
return x % 2 == 0
def is_odd(x):
return x % 2 == 1
def double(x):
return x * 2
def triple(x):
return x * 3
result = pattern_match(
[
(is_even, double),
(is_odd, triple),
],
default=lambda x: x,
)(5)
print(result) # Output: 15
In this example, we create a Pipe object that applies the pattern_match function to an input value of 5. The pattern_match function selects the triple function because 5 is an odd number, and applies it to the input value. The output of the pipeline is 15.
Installation You can install the library using pip:
pip install funcpipe
License This library is licensed under the MIT License.
Metadata
Release files for funcpipe 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| funcpipe-0.3.0.tar.gz | 3.1 kB | Without provenance | Details for funcpipe-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| funcpipe-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for funcpipe-0.3.0-py3-none-any.whl |
Total release size: 6.6 kB
Release files / funcpipe-0.3.0.tar.gz
| Download URL | funcpipe-0.3.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
155e6b374eaee9743c21d24bb2b31f7a0ff33bdfe71b92bb2ce992d0ee07dcb2
|
|
BLAKE2b-256 checksum How to use checksums |
bfad622e3350817bf3fdcc5dc6778ffb4f2429bd9472772549a43b7bef0416cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.8.10 Linux/5.15.90.1-microsoft-standard-WSL2
|
Release files / funcpipe-0.3.0-py3-none-any.whl
| Download URL | funcpipe-0.3.0-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0dee1df0995a706945eb2dbb74126c693191bcbafcdd8c7596ecab688bf7883e
|
|
BLAKE2b-256 checksum How to use checksums |
4a49f95da554fe90e8ec64f7fc4fb5b9b003dd6aee4703492191b24efd0a4dd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.8.10 Linux/5.15.90.1-microsoft-standard-WSL2
|
Security for funcpipe 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.