https://github.com/olegalexander/oa-utils
Statically typed Python utilities for functional programming.
https://github.com/olegalexander/oa-utils
collection-pipeline fluent-interface functional-programming utilities-python
Last synced: 3 days ago
JSON representation
Statically typed Python utilities for functional programming.
- Host: GitHub
- URL: https://github.com/olegalexander/oa-utils
- Owner: OlegAlexander
- License: mit
- Created: 2025-05-18T23:20:30.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-14T22:44:34.000Z (6 months ago)
- Last Synced: 2025-10-27T09:48:43.884Z (4 months ago)
- Topics: collection-pipeline, fluent-interface, functional-programming, utilities-python
- Language: Python
- Homepage: https://pypi.org/project/oa-utils/
- Size: 43.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# oa-utils
Statically typed Python utilities for functional programming.
## Pipeline
This class is useful for programming in the [collection pipeline](https://martinfowler.com/articles/collection-pipeline/) style. It wraps a homogenous variadic tuple and exposes a fluent interface with common functional programming operations. Why a tuple and not a "lazy" iterator? Because a tuple is relatively immutable and because, in my opinion, reified collections are much easier to reason about than stateful iterators (at the expense of performance).
```python
from oa_utils import Pipeline
hamming_distance = (
Pipeline("karolin") # ('k', 'a', 'r', 'o', 'l', 'i', 'n')
.zip_with(lambda a, b: int(a != b), "kathrin") # (0, 0, 1, 1, 1, 0, 0)
.sum() # 3
)
```
See [pipeline.py](https://github.com/OlegAlexander/oa-utils/blob/main/oa_utils/pipeline.py) for docstrings and doctests of every method.