Of what use is 'lambda'???

piet at cs.uu.nl piet at cs.uu.nl
Tue Sep 19 11:25:55 CEST 2000


>>>>> tye4 <tye4 at yahoo.com> (T) writes:

T> The lambda definition is limited to only one expression, and everything
T> you do with lambda, can also be done with plain functions.

>>>> adder1 = lamda a, b : a + b
>>>> def dosum(a, b):
T>         return a + b

>>>> adder2 = dosum

>>>> adder1(2, 3)
T> 5

>>>> adder2(2, 3)
T> 5

T> So, does lamda have a feature that regulars funcs have or is just there
T> for convenience??

Its main purpose is convenience so that you don't have to invent a name and
to separate your function from the place where you have to supply it as a
parameter.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl



More information about the Python-list mailing list