lambda expressions

Bas van Gils bas.vangils at home.nl
Sun Feb 3 17:14:55 CET 2002


On Sun, Feb 03, 2002 at 02:55:16PM +0000, Gerson Kurz wrote:
> [snip]
>
> Well, you can do that right now (given 2.2)! For example, take this
> very useless sample code
> -------------------------
> a, b = 0, 10
> while a < b:
> 	print a
> 	a += 1
> -------------------------
>
> [snip]
>
> Now, we can write the above code simply as
> -------------------------
> w = lambda x=[10,0]:
> WHILE(lambda:(x[1]<x[0]),lambda:(OUT(x[1]),x.__setitem__(1,x[1]+1)))
> 
> -------------------------
>
> [snip]


Thanks for the explanations so far... I think the lambda-version is more
difficult to understand then the `original' version. From the examples
that I've seen, this is (almost) always true. Being only a `mediocre'
programmer, I value readability a lot. Guess I won't be using lamba's a
lot.

Having read the recent thread on timing how fast code exectes, though, I
wonder: are lambda-statments _faster_ ?

    cheers

        Bas

-- 
Bas van Gils <bas.vangils at home.nl>   -    http://members.home.nl/bas.vangils
Build a system that even a fool can use, and only a fool will want to use it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020203/5d3fc459/attachment.sig>


More information about the Python-list mailing list