+1<br><br><div class="gmail_quote">On Tue, May 10, 2011 at 12:49 AM, Daniel Fischer <span dir="ltr">&lt;<a href="mailto:daniel.is.fischer@googlemail.com">daniel.is.fischer@googlemail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I would like to propose the elimination of the special error case<br>
<br>
gcd 0 0 = error &quot;Prelude.gcd: gcd 0 0 is undefined&quot;<br>
<br>
to replace it with<br>
<br>
gcd 0 0 = 0<br>
<br>
(which would be an automatic consequence of removing the above line).<br>
<br>
Rationale:<br>
<br>
1. It makes gcd a total function.<br>
2. It makes gcd associative.<br>
3. It makes folding gcd over a list safe.<br>
4. It conforms to common mathematical practice:<br>
<br>
In a commutative ring, a greatest common divisor of two elements a, b is<br>
a common divisor g of a and b such that every common divisor d of a and b<br>
also divides g (if R is a commutative ring, a \in R, d \in R is a divisor<br>
of a iff there exists c \in R with a = d*c [leaving out noncommutative<br>
rings for simplicity]).<br>
Since every ring element divides 0, the above definition entails<br>
gcd 0 0 = 0.<br>
<br>
Further, in a principal ideal ring, the greatest common divisors of two<br>
elements a and b are the generators of the ideal (a,b), again that<br>
characterisation of greatest common divisors says gcd 0 0 = 0:<br>
(0,0) = {0} = (0).<br>
<br>
Pros: see above.<br>
<br>
Cons: ?<br>
I&#39;m not aware of any, the change shouldn&#39;t break existing code, since that<br>
would have to check for the special case anyway.<br>
<br>
Daniel<br>
<br>
_______________________________________________<br>
Haskell-prime mailing list<br>
<a href="mailto:Haskell-prime@haskell.org">Haskell-prime@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-prime" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-prime</a><br>
</blockquote></div><br>