Theoretical question about Lambda

Bengt Richter bokr at oz.net
Thu May 2 12:21:57 EDT 2002


On Thu, 02 May 2002 09:03:44 GMT, Alex Martelli <aleax at aleax.it> wrote:

>pekka niiranen wrote:
>
>> After reading about Scheme, I begun to wonder:
>> 
>> Is there any forced need for Lambda's in Python ? I mean does Lambda
>> contribute anything that cannot be done otherwise in Python ?
>
>Not really.  lambda lets you have an anonymous function, and create
>a function within an expression (while def is a statement and does
A thought: being ble to do it in an expression allows taking advantage
of short-circuit evaluation to avoid some problem in a lambda def form
vs another.

>require a name), so you may be able to collapse a few things a little
>bit more, in theory, e.g.:
>
>        funs = [lambda x: x+1, lambda x: x*2]
>
>vs:
>
>        def plus1(x): return x+1
>        def times2(x): return x*2
>        funs = [plus1, times2]
>
>but that's about it.
>
What do you think re short circuit evaluation vav lambda?

Regards,
Bengt Richter



More information about the Python-list mailing list