This module provides functions known from functional programming languages.
Returns a function which acts as a composition of several functions. If one function is given it is returned if no function is given a TypeError is raised.
>>> from brownie.functional import compose
>>> compose(lambda x: x + 1, lambda x: x * 2)(1)
3
Note
Each function (except the last one) has to take the result of the last function as argument.
Returns a function which behaves like function but gets the given positional arguments reversed; keyword arguments are passed through.
>>> from brownie.functional import flip
>>> def f(a, b): return a
>>> f(1, 2)
1
>>> flip(f)(1, 2)
2
A named tuple representing a function signature.
Parameters: |
|
---|
Warning
The size of Signature tuples may change in the future to accommodate additional information like annotations. Therefore you should not rely on it.
New in version 0.5.
curried is a decorator providing currying for callable objects.
Each call to the curried callable returns a new curried object unless it is called with every argument required for a ‘successful’ call to the function:
>>> foo = curried(lambda a, b, c: a + b * c)
>>> foo(1, 2, 3)
6
>>> bar = foo(c=2)
>>> bar(2, 3)
8
>>> baz = bar(3)
>>> baz(3)
9
By the way if the function takes arbitrary positional and/or keyword arguments this will work as expected.
New in version 0.5.