Skip to content

agnostism/sayori

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation



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