|
|
Re: 0^0=1
Posted:
May 2, 2012 10:41 PM
|
|
In article <3d9c46fc-7b90-4dfc-9161-b6d240725a60@ee2g2000vbb.googlegroups.com>, Dan Christensen <Dan_Christensen@sympatico.ca> wrote:
> On May 2, 6:13 pm, Gus Gassmann <horand.gassm...@googlemail.com> > wrote: > > On May 2, 5:33 pm, Dan Christensen <Dan_Christen...@sympatico.ca> > > wrote: > > > > > Like I said, it depends on your application, but I don't see how you > > > can sensibly assign any number to the sum or product of an empty list > > > of numbers. Not from a programming perspective anyway. > > > > Holy smokes, Dan. I've seen you say some pretty asinine things, but > > this one surely takes the cake. > > > > *Especially* from a programming perspective it makes eminent sense to > > assign 0 to the sum of an empty list of numbers and 1 to the product: > > > > From a programming perspective, if you aren't given anything to add or > multiply how much sense does it make to return any numerical answer > from a sum or product function? Get real!
But it is real. Same thing is done for the factorial of 0 and the concatenation of an empty array of strings (i.e., the array is an array of strings and the number of elements in the array happens to be zero). In particular, 0 factorial is 1 and the concatenation of the string array [] is "".
Likewise, the union of an empty collection of sets is the empty set, while the intersection of an empty collection of sets is the universal set (assuming that there is a universal set, or at least a set that every set being talked about is a subset).
> > > > unsigned int n; > > new double x[n]; > > double prod = 1, sum = 0; > > for (j=0; j <n; j++) > > { > > sum = sum + x[j]; > > prod = prod * x[j]; > > > > } > > > > > Surely even you can understand that it is better to program, compile > > and execute the loop in this form without any artificial if statement > > to cater to special cases such as n=0 or n=1. > > Huh? You've never programmed anything more complicated than your alarm > clock, have you, Gus? > > Dan > Download my DC Proof 2.0 software at http://www.dcproof.com > Also see video demo
|
|