Add uncurry2
This commit is contained in:
parent
8d3edb1ea8
commit
46bbcca1b8
|
@ -140,6 +140,20 @@ def cur3(f: Callable[Concatenate[A, B, P], D]) -> Callable[[A], Callable[[B], Ca
|
|||
"""
|
||||
return p(p, p, f) #type:ignore
|
||||
|
||||
def uncurry2(f: Callable[[A], Callable[P, B]]) -> Callable[Concatenate[A, P], B]:
|
||||
"""
|
||||
Uncurries a two-argument function
|
||||
|
||||
The inverse of `cur2`
|
||||
|
||||
>>> uncurry2(lambda x: lambda y: f'{x} {y}')('hello', 'world')
|
||||
'hello world'
|
||||
"""
|
||||
@wraps(f)
|
||||
def inner(a: A, *args: P.args, **kwargs: P.kwargs) -> B:
|
||||
return f(a)(*args, **kwargs)
|
||||
return inner
|
||||
|
||||
|
||||
# Curried versions of map & filter with stricter types
|
||||
def p_map(f: Callable[[A], B]) -> Callable[[Sequence[A]], Sequence[B]]:
|
||||
|
|
Loading…
Reference in a new issue