HOFU
A simple, fast and lightweight HOF (higher order functions) library for python.
This library allows you to use HOFs in a simple way, comparable to JavaScript its HOF and the Rust iterator.
Installation
pip install hofu
Example
from hofu import Iterator
Iterator(range(10)) \
.map(lambda x: x ** 2) \
.filter(lambda x: x % 2 == 0 and x != 0) \
.map(lambda x: "Next even power is " + str(x)) \
.for_each(print)
# +- equivalent to sum(range(10))
total = Iterator(range(10)).reduce(lambda x, y: x + y)
print("Sum of 1-10:", total)
Iterator(range(10)) \
.rev() \
.skip(5) \
.take(2) \
.map(lambda x: "Next number: " + str(x)) \
.for_each(print)
people = [
{"name": "John", "age": 30},
{"name": "Jane", "age": 25},
{"name": "Bob", "age": 40},
{"name": "Alice", "age": 35},
]
average_age = Iterator(people).reduce(lambda x, y: x + y["age"], 0) / len(people)
print("Average age:", average_age)
data = Iterator(range(10)).filter(lambda x: x % 2 == 0).collect()
print("Even numbers:", list(data))
even_formatted = Iterator(range(10)).map(lambda x: f"{x}={'even' if x % 2 == 0 else 'odd'}").collect()
print("Even/odd:", list(even_formatted))
Metadata
Release files for hofu 0.0.1
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 | |
|---|---|---|---|---|
| hofu-0.0.1.tar.gz | 3.9 kB | Without provenance | Details |
Release files / hofu-0.0.1.tar.gz
| Download URL | hofu-0.0.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36f94e511dd47cbce73cf65d45878a0255760238d0b6cda0d99f21e287aa2590
|
|
BLAKE2b-256 checksum How to use checksums |
792597f504b56531f6480b16cf98d0ab8062b67d24f3228d80b1137d8fc8ea2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for hofu 0.0.1
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.