[Tutor] can someone explain to me Lambda functions/statements, preferably with examples, I don't get it

Steve Spicklemire steve@spvi.com
Wed, 23 Aug 2000 05:36:02 -0500 (EST)


Hi Charles,

Lambda is used to make a function:

e.g., 

You could say 

def foo(x):
    return x - 3*x + 4*x**2
and then use foo in another situation where a function is required:

print map(foo, [1,2,3,4,5])

[2, 12, 30, 56, 90]

a shorter definition would be using lambda

bar = lambda x : x - 3*x + 4*x**2 

print map(bar, [1,2,3,4,5])