I've reconsidered my earlier position and think now that the Prelude is wrong to make gcd 0 0 an error, and should return 0. It probably doesn't make much difference to anyone, but it's like 1 not being a prime; it may be slightly harder to explain, but it makes the maths come out nicer and is in the end a simplification.
"George" == George Russell <ger@tzi.de> writes:
George> I've reconsidered my earlier position and think now that the George> Prelude is wrong to make gcd 0 0 an error, and should return George> 0. It probably doesn't make much difference to anyone, but George> it's like 1 not being a prime; it may be slightly harder to George> explain, but it makes the maths come out nicer and is in the George> end a simplification. I'm strongly against making 1 a prime number. In contrast, 0*x=0, thus 0 "divides" 0 (somehow). But I have problems with "gcd being the greatest positive integer ..." - 0 is not positive, it is non-negative or natural - 2 also divides 0 and 2 is a "greater integer" than 0 (0 is the top element of the lattice formed by the division relation but that is not clear by the expression "greatest") Anyway, gcd 0 0 = error would be the simplest way to avoid confusion and catch accidental programming errors; e.g., using the gcd to divide something else. -- Christoph
Ch. A. Herrmann (herrmann@infosun.fmi.uni-passau.de) wrote: : In contrast, 0*x=0, thus 0 "divides" 0 (somehow). : But I have problems with "gcd being the greatest positive integer ..." [snip] : - 0 is not positive, it is non-negative or natural : - 2 also divides 0 and 2 is a "greater integer" than 0 : (0 is the top element of the lattice formed by the division relation : but that is not clear by the expression "greatest") : gcd a b is the greatest non-negative integer dividing both a and b such that anything that divides both a and b also divides gcd a b (so gcd a b is the greatest thing that divides both a and b). Regards, Marc van Dongen -- Marc van Dongen | dongen@cs.ucc.ie | Computer Science Department | Western Road | () ASCII ribbon campaign University College Cork | Cork, Ireland | /\ against HTML mail phone: +353 (0)21 4903578 | fax: 4903113 |
participants (3)
-
Ch. A. Herrmann -
George Russell -
Marc van Dongen