writing recursive lambda functions

tutu milas_gi at hotmail.com
Wed Dec 24 10:41:50 EST 2003


??? Is this what you need?
def mapp(f):
     lambda l: l and cons(f(car(l)),(mapp(f)(cdr(l))))
print mapp(lambda x: x*x) => None  (can't call it)

def mapp(f):
     return lambda l: l and cons(f(car(l)),(mapp(f)(cdr(l))))
print mapp(lambda x: x*x) => <function <lambda> at 0x0267ED30>

print "mapQuad([1,2,3,4]): ", mapQuad([1,2,3])
=> mapQuad([1,2,3,4]):  [1, 4, 9]




More information about the Python-list mailing list