agnostism / sayori

Compose functions using pipeline notation.

Home Page:https://pypi.org/project/sayori

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool



Sayori

Sayori is a tiny library for composing pure functions using pipeline notation. If f and g are functions then f | g is a function such that (f | g)(x) = g(f(x)).

Installation

pip install sayori

Usage

Sayori exports a simple decorator called Composable which implements the pipe operator. It can be used as follows:

from sayori import Composable

Create two composable functions...

f = Composable(lambda x: x + 1)

g = Composable(lambda x: x * 2)

Compose them...

h = f | g

Apply the composite...

h(2)  # returns 6

About

Compose functions using pipeline notation.

https://pypi.org/project/sayori

License:MIT License


Languages

Language:Python 100.0%