compose

xam ma at Bell.com
Mon May 5 00:56:32 EDT 2003


i've been truing to get this 'simple' code to work,
def compose(*funcs):
...  if len(funcs)>1:
...    return lambda x:funcs[0](compose(funcs[1:])(x))
...  else:  return lambda x:funcs[0](x)
>>> compose(add_5, mul_3, sub_2)(2)
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "<interactive input>", line 3, in <lambda>
  File "<interactive input>", line 4, in <lambda>
TypeError: 'tuple' object is not callable
does anyone want to give it a shot?






More information about the Python-list mailing list