Skip to main content

True functional programming in Python

Project description

Actions Status Python 3.10 Stable Version Code style: black Checked with mypy

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


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)

Uploaded Source

Built Distribution

functon-0.0.2.dev0-py3-none-any.whl (3.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page