This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
def pass_result_to(wrap_with): | |
def wrapper(f): | |
def wrapper_(*args, **kwargs): | |
return wrap_with(f(*args, **kwargs)) | |
return wrapper_ | |
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = [lambda x: x*x, lambda y: y+y, lambda z: str(z)] | |
comp = lambda fs, arg: reduce(lambda x, y: y(x), fs, arg) | |
comp(fs, 5) # returns '50', i.e. str((5*5)+(5*5)) |
OlderNewer