Functional currying in Python. 🥘
Project description
🥘 Curry fp
Functional currying for Python.
Simple ⬦ Clear ⬦ Concise
Background
Currying is a technique targeting strategic code composition, breaking apart a function into a series of functions, allowing arguments to be applied piece-by-piece until all parameters are fulfilled.
Usage
Curry fp is a powerful tool that can be used as a decorator on Callable objects for the purpose of currying.
Features
- Allows for 1 or more arguments to be passed to the curried function at a time, including all at once.
- Default values can be specified using
... (Ellipsis)as an argument, at any point. - Keyword arguments can be used, allowing for arguments to be passed in whenever available.
Example
from curry_fp import curry
@curry
def sum_all(a: int, b: int=2, c: int=3) -> int:
return a + b + c
Without using default values
>>> sum_all(1)(2)(3)
6
Using default values
>>> sum_all(1)(...)
6
All arguments at once
>>> sum_all(1, 2, 3)
6
All arguments at once (with defaults)
>>> sum_all(1, 2, ...)
6
Using keyword arguments in any order
>>> sum_all(b=2)(c=3)(a=1)
6
See test/test_curry.py for more examples. ✨
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
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 curry_fp-1.3.3.tar.gz.
File metadata
- Download URL: curry_fp-1.3.3.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4dba72461543bd77da9bc6b5bbe5ea21ded3fc72cc28fa0c26b77dfdd1ec430
|
|
| MD5 |
eff7674463e8d3ea675c0e347c94acbe
|
|
| BLAKE2b-256 |
6599a781d7c570e18cd8f3f01754e59de62ed231cdc60f7ffaa18f7e6fc3e55f
|
File details
Details for the file curry_fp-1.3.3-py3-none-any.whl.
File metadata
- Download URL: curry_fp-1.3.3-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Linux/5.15.167.4-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c217191895b3fc7d6c0c80e9d06c48739f5f629a91437ddfe00cf7b2a782128c
|
|
| MD5 |
421ecd4b44a442a6df4d9fed6ad1fed5
|
|
| BLAKE2b-256 |
5297475544afb4ad39bcc888ae12dc8664fef5680acab46113370246b18ee89e
|