Functional Pipelines implemented in python
Project description
Functional Pipeline
Functional languages like Haskell, Elixir, and Elm have pipe functions that allow the results of one function to be passed to the next function.
Using functions from functools
, we can build composition in python, however it is not
nearly as elegant as a well thought out pipeline.
This library is designed to make the creation of a functional pipeline easier in python.
>>> from operator import add, mul
>>> from functional_pipeline import pipeline, tap
>>> result = pipeline(
... 10,
... [
... (add, 1),
... (mul, 2)
... ]
... )
>>> result
22
This pattern can be extended for easily dealing with lists or generators.
>>> from functional_pipeline import pipeline, String, join
>>> names = [
... "John",
... "James",
... "Bill",
... "Tiffany",
... "Jamie",
... ]
>>> result = pipeline(
... names,
... [
... (filter, String.startswith('J')),
... (map, lambda x: x + " Smith"),
... join(", "),
... ]
... )
>>> result
'John Smith, James Smith, Jamie Smith'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file functional_pipeline-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: functional_pipeline-0.6.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdda3bccfb42cfc6393ae3e895a196e6f7041d80d698748403406a81d70cba22 |
|
MD5 | 4ce9a4692d1756b8e1ab3930d046ddc4 |
|
BLAKE2b-256 | 095c1315e5b1f498c953fbf3c20e17c1bbfb5fefcc648bc46638ef64d58d7f97 |