Module pywander.functools
Functions
def build_compose_function(*funcs)-
Expand source code
def build_compose_function(*funcs): """ combine a sequence functions to a compose function """ return reduce(lambda f, g: lambda *args, **kwargs: g(f(*args, **kwargs)), funcs)combine a sequence functions to a compose function
def build_stream_function(*funcs)-
Expand source code
def build_stream_function(*funcs): """ combine a sequence funtion to a compose function, and for the sake of simplicity, limited the input parameter to a dict object. """ return reduce(lambda f, g: lambda d: g(f(d)), funcs)combine a sequence funtion to a compose function, and for the sake of simplicity, limited the input parameter to a dict object.
def default_func(n)-
Expand source code
def default_func(n): print(n) def mathematical_induction(n, func=<function default_func>)-
Expand source code
def mathematical_induction(n, func=default_func): if n==1: return default_func(1) else: return mathematical_induction(n-1) def sumall(*args)-
Expand source code
def sumall(*args): """sum all numbers, support multiple layer structure. >>> sumall(1,1,2,3,[1,2,3]) 13 >>> sumall(1,1,2,3,[1,2,3],(4,5,6),[[5,5],[6]]) 44 >>> """ args = flatten(args) return sum(args)sum all numbers, support multiple layer structure.
>>> sumall(1,1,2,3,[1,2,3]) 13 >>> sumall(1,1,2,3,[1,2,3],(4,5,6),[[5,5],[6]]) 44 >>>