I'll put this in the Cookbook entry I'm preparing, along with curry. class compose: '''Compose two functions.''' def __init__(self, f, g): self.f = f self.g = g def __call__(self, *arg, **kwarg ): return self.f(self.g(*arg, **kwarg)) test: from math import sin, cos sincos = compose(sin, cos) cossin = compose(cos, sin) for x in range(10): assert sincos(x) == sin(cos(x)) assert cossin(x) == cos(sin(x)) -Scott David Daniels
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4