On Fri, Sep 5, 2008 at 11:45 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Fri, 05 Sep 2008 22:20:06 -0400, Manu Hack wrote: > >> On Fri, Sep 5, 2008 at 1:04 PM, castironpi <[EMAIL PROTECTED]> wrote: > ... >>>> >The reason sum([]) is 0 is that sum( [ x ] ) - x = 0. >>>> >>>> It doesn't make sense to me. What do you set x to? >>> >>> For all x. >> >> But then how can you conclude sum([]) = 0 from there? It's way far from >> obvious. > > I think Castironpi's reasoning is to imagine taking sum([x])-x for *any* > possible x (where subtraction and addition is defined). Naturally you > always get 0. > > Now replace x by *nothing at all* and you get: > > sum([]) "subtract nothing at all" = 0 > > I think that this is a reasonable way to *informally* think about the > question, but it's not mathematically sound, because if you replace x > with "nothing at all" you either get: > > sum([]) - = 0 > > which is invalid (only one operand to the subtraction operator), or you > get: > > sum([0]) - 0 = 0 > > which doesn't involve an empty list. What castironpi seems to be doing is > replacing "nothing at all" with, er, nothing at all in one place, and > zero in the other. And that's what makes it unsound and only suitable as > an informal argument.
Actually it's even more natural to state sum([x]) = x, and this way you can never conclude that sum([]) = 0 from there. -- http://mail.python.org/mailman/listinfo/python-list