Proposal: Make gcd total

Henning Thielemann schlepptop at henning-thielemann.de
Thu Jun 2 23:42:01 CEST 2011


Ross Paterson schrieb:
> On 28 May 2011 11:59, Daniel Fischer wrote:
>> I would like to propose the elimination of the special error case
>>
>> gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined"
> 
> Just deleting that line sounds good.  For documentation, I'd suggest:
> 
>   gcd x y is the non-negative factor of both x and y of which every
>   common factor of x and y is also a factor; for example gcd 4 6 = 2,
>   gcd (-4) 6 = 2, gcd (-4) (-6) = 2, gcd 0 4 = 4, gcd 0 0 = 0.
>   (That is, the common divisor that is "greatest" in the divisibility
>   ordering.)

... and   gcd 0 (-4) = 4, that is, 0 is not an identity element. :-(




More information about the Libraries mailing list