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
Metadata
Release files for funcie 0.2.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 | |
|---|---|---|---|
| funcie-0.2.0.tar.gz | 54.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| funcie-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 61.1 kB
Release files / funcie-0.2.0.tar.gz
| Download URL | funcie-0.2.0.tar.gz |
|---|---|
| Size | 54.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ad3a8d8bb77a8357bab76fbff2b877811a8e2bae7ea2edcf9e5c2c65ad2e33c
|
|
BLAKE2b-256 checksum How to use checksums |
e940ed341707a5054ce0e567c116ecdd5f0f7e224c6d9a6d5c7701c4d12cdbb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / funcie-0.2.0-py3-none-any.whl
| Download URL | funcie-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4a559b6b49921036f20cdc384fd618f554037e6bd33ea7d52d24500e094874e5
|
|
BLAKE2b-256 checksum How to use checksums |
8fafe125ce9f7b7a87c382ff38b0b2b1e872a885f4b3664fb5e56b8cf852df44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|