Functional programming helpers for Python.
Project description
funcie
funcie is a focused Python library of functional programming helpers.
What you get
- Function composition:
compose,pipe,composable - Predicate composition:
predicatewith&,|,^,~ - Predicate helpers:
all_pass,any_pass,none_pass,complement - Currying:
curry,curry_n,curried - Collection helpers:
keep,reject,flat_map,take,drop,partition,fold
Install
uv sync --group dev
Quick examples
Composition
from funcie import compose, pipe, composable
add1 = lambda x: x + 1
mul2 = lambda x: x * 2
assert compose(add1, mul2)(3) == 7
assert pipe(add1, mul2)(3) == 8
c_add1 = composable(add1)
c_mul2 = composable(mul2)
assert (c_add1 >> c_mul2)(3) == 8
assert (c_add1 @ c_mul2)(3) == (4, 6)
Predicates
from funcie import predicate
is_even = predicate(lambda n: n % 2 == 0)
is_positive = predicate(lambda n: n > 0)
is_positive_even = is_even & is_positive
is_odd = ~is_even
assert is_positive_even(4) is True
assert is_positive_even(-2) is False
assert is_odd(5) is True
Currying
from funcie import curried
@curried
def add(a, b, c):
return a + b + c
assert add(1)(2)(3) == 6
Development
make ci
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 Distribution
funcie-0.2.0.tar.gz
(54.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file funcie-0.2.0.tar.gz.
File metadata
- Download URL: funcie-0.2.0.tar.gz
- Upload date:
- Size: 54.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ad3a8d8bb77a8357bab76fbff2b877811a8e2bae7ea2edcf9e5c2c65ad2e33c
|
|
| MD5 |
50ff0fa80de6c6a4f3a63ffaa63df7aa
|
|
| BLAKE2b-256 |
e940ed341707a5054ce0e567c116ecdd5f0f7e224c6d9a6d5c7701c4d12cdbb0
|
File details
Details for the file funcie-0.2.0-py3-none-any.whl.
File metadata
- Download URL: funcie-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a559b6b49921036f20cdc384fd618f554037e6bd33ea7d52d24500e094874e5
|
|
| MD5 |
843493c269e726757e2df0bf25b28782
|
|
| BLAKE2b-256 |
8fafe125ce9f7b7a87c382ff38b0b2b1e872a885f4b3664fb5e56b8cf852df44
|