Function composition

Emile van Sebille emile at fenx.com
Wed Aug 2 18:18:09 EDT 2000


How about something like:

def compose(f, *args, **kwargs):
  return apply(f, args, kwargs)


--

Emile van Sebille
emile at fenx.com
-------------------


"Cees de Groot" <cg at gaia.cdg.acriter.nl> wrote in message
news:8ma4g2$t57$1 at gaia.cdg.acriter.nl...
> 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