29 lines
459 B
Python
29 lines
459 B
Python
from itertools import starmap
|
|
|
|
from funcy import iterate, first, curry, map
|
|
from pymonad.either import Left, Right
|
|
|
|
|
|
def until(cond, func, *args, **kwargs):
|
|
return first(filter(cond, iterate(func, *args, **kwargs)))
|
|
|
|
|
|
def lift(fn):
|
|
return curry(map)(fn)
|
|
|
|
|
|
def starlift(fn):
|
|
return curry(starmap)(fn)
|
|
|
|
|
|
def bottom(*args, **kwargs):
|
|
return None
|
|
|
|
|
|
def left(fn):
|
|
return lambda x: Left(fn(x))
|
|
|
|
|
|
def right(fn):
|
|
return lambda x: Right(fn(x))
|