Function composition

Cees de Groot cg at gaia.cdg.acriter.nl
Wed Aug 2 17:40:18 EDT 2000


I was showing a Math PhD/Functional programming guy Python, and of course he
was interested in map, filter, etcetera. He talked about function composition,
and I did a quick:

def compose(f, g): return lambda x: f(g(x))

but that's of course only for single-argument functions. My
advanced-Python-hacking seems to be getting rusty (too much Java coding, sorry
for that), but is there an easy way to extend this to any argument signature?

TIA,

Cees
-- 
Cees de Groot               http://www.cdegroot.com     <cg at cdegroot.com>
GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD  1986 F303 937F E098 9E8B
Forge your CipherSaber and list it: http://www.xs4all.nl/~cg/ciphersaber/



More information about the Python-list mailing list