On 3/10/06, Alan Gauld <[EMAIL PROTECTED]> wrote:
Much more readable.
Anna
>> Could you please explain this code?.
>>
>> f = lambda n: n-1 + abs(n-1) and f(n-1)*n or 1
>
>
>This is why lambdas are evil.
I meant to add to my last post that even using lambdas this
is a weird attempt at a factorial fiunction.
Here's the equivalent from my web tutor on functional
programming:
>>> factorial = lambda n: ( (n <= 1) and 1) or
... (factorial(n-1) * n)
>>> factorial(5)
120
It uses the same basic constructs but much less esoteric trickery.
Hopefully its slightly more readable,
Much more readable.
Anna
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor