Marshall
Posts:
1,928
Registered:
8/9/06
|
|
Re: 0^0=1
Posted:
May 5, 2012 1:35 PM
|
|
On Friday, May 4, 2012 8:43:55 PM UTC-7, Dan Christensen wrote: > On May 4, 7:48 pm, Marshall <marshall.spi...@gmail.com> wrote: > > On Friday, May 4, 2012 9:01:55 AM UTC-7, Gus Gassmann wrote: > > > > > Fact is, sums, products, minima, maxima and string concatenations can > > > be defined consistently over empty lists, and one should do so in > > > order to avoid unnecessary case distinctions. > > > > Yes; more generally, the n-ary form of any binary function with > > an identity can (should!) be defined to be that identity in the > > arity-0 case. For example: > > > > AND(true, false, true) = false; > > AND(true, false) = false; > > AND(true) = true; > > AND() = true; > > > > All the same reasoning for empty products applies. This is > > widely understood in the CS field. > > > > (Min and max have identities for quantities like 32-bit integer > > but don't in the general case.) > > > > Gus's earlier example program was entirely canonical and > > ordinary; Dan's suggestion to complicate it by adding > > extra checking make for a worse program. > > > > Under what conditions should a product function return a value of 1? > How about only when the the numbers supplied to it multiply to give > you 1.
Yes, exactly. Just like Gus's code does, and the LISP n-ary product does, and the earlier mentioned fold function present in functional languages.
Marshall
|
|