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.1.1.tar.gz
(41.6 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.1.1.tar.gz.
File metadata
- Download URL: funcie-0.1.1.tar.gz
- Upload date:
- Size: 41.6 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 |
340adaed06b6aa4c0e7b721843335c0c87de82052df383411ed9c0bc0397383a
|
|
| MD5 |
7ad99431c6632a85047b72c4d21d6846
|
|
| BLAKE2b-256 |
03bdbe3e8780f5efa527bc91c27087f66d15910bf8a4fb9f67c0d717c8bd13eb
|
File details
Details for the file funcie-0.1.1-py3-none-any.whl.
File metadata
- Download URL: funcie-0.1.1-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 |
5175ba626b56daecc29f4930aa7a97b4f8cf17ae99f0d8b105534dd0fafcbf13
|
|
| MD5 |
13b4fbea62a29fadccf8d4df3251e6d3
|
|
| BLAKE2b-256 |
8c7b4da971708fb9bdaf4904060a89d3686289a91b2aeb27f8161dfb6fa48ed0
|