code like this: pipe(1) | float | str | list | done
!
pip install pipeto
-
pipe(arg)
generate a pipable object pipe to next function.
@param : arg {mixed} -
done(arg)
get the actural value out of pipable object -
compose(fn)
Compose functions. Can be used as a decorator.
@alias : composable
@param : fn {callable}
from pipeto import *
import operator as op
inc = lambda x: x + 1
double = lambda x: x + x
# pipe
pipe(1) | float | str | list | done # == ['1', '.', '0']
pipe(2) | inc | done # == 3
pipe(2) | inc | double | done # == 6
pipe([1,2,3]) | sum | done # == 6
# compose
newfn = compose(inc) | double
newfn(2) # == double(inc(2))