writing recursive lambda functions

JCM joshway_without_spam at myway.com
Wed Dec 24 07:33:46 EST 2003


> def mapp(f):
>     lambda l: l and cons(f(car(l)),(mapp(f)(cdr(l))))

You're missing a return here:

def mapp(f):
    return lambda l: l and cons(f(car(l)),(mapp(f)(cdr(l))))

A common mistake if you're coming from lisp (I do it all the time).




More information about the Python-list mailing list