Created
June 30, 2009 23:09
-
-
Save minimal/138490 to your computer and use it in GitHub Desktop.
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
import functional | |
def MultiCompose(*funcs): | |
"""Return a function composed of many functions | |
MultiCompose(f, g, h) == f(g(h)) | |
""" | |
return functional.partial(reduce, functional.compose)(funcs) | |
def ThreadFuncs(*funcs): | |
"""Thread funcs into eachother from left to right | |
ThreadFuncs(f, g, h) == h(g(f)) | |
""" | |
return functional.partial(reduce, functional.compose)(reversed(funcs)) | |
def thread_funcs(arg, *funcs): | |
"""Thread funcs into eachother from left to right and run func with | |
args | |
""" | |
return functional.partial(reduce, functional.compose)(reversed(funcs))(arg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment