>> 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, but I still wouldn't recommend it as a way to write everyday code! HTH Alan G Author of the learn to program web tutor http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor