On 2:59 PM, Xavier Ho wrote:
On 27 October 2010 18:27, Arnaud Delobelle<arno...@gmail.com> wrote:
True. It's far too verbose. I'd go for something like:
f=lambda n:n<=0 or n*f(~-n)
I've saved a few precious keystrokes and used the very handy ~- idiom!
Huh, I've never seen that one before. Seems to work on both positive and
negative numbers. Is there a caveat to this?
Cheers,
Xav
The ~- trick only works on two's complement numbers. I've worked on
machines in the past that used one's complement, and this wouldn't work
there.
DaveA
--
http://mail.python.org/mailman/listinfo/python-list