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))
.
pip install sayori
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