True functional programming in Python
Project description
Functon λ [EXPERIMENTAL]
Installation
python3 -m pip install functon
Usage
Hello world:
>>> from functon import fn
>>> fn(print, "Hello world!")
'Hello world!'
Triple the value of a number:
>>> from functon import defun, fn
>>> def triple(x: int) -> defun(("*", 3, "x")):
... """Compute three times X."""
>>> fn(triple, 3)
9
Compute factorials using recursion:
>>> from functon import defun, fn, IF
>>> def factorial(N: int) -> defun((IF, ("=", "N", 1), 1, ("*", "N", ("factorial", ("-", "N", 1))))):
... """Compute the factorial of N."""
>>> fn(factorial, 5)
120
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
functon-0.0.2.dev0.tar.gz
(2.9 kB
view hashes)
Built Distribution
Close
Hashes for functon-0.0.2.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f74cf92444aaf7544e973a3c7b07d87623477db57f6f906f42b5b57dd9ecdf08 |
|
MD5 | 0ea024e0abbca60e4fd0c014b701a242 |
|
BLAKE2b-256 | 4734f95345e41908bb7ae06ef98d1ed24496ed7e8e52a358fa2795a8b996f69b |