4 ms·
Well... kind of. You can define a gcd operation on arbitrary commutative rings, but two elements of the ring don't necessarily have a unique gcd. If you want a
by crntaylor 14y ago
Well... kind of. You can define a gcd operation on arbitrary commutative rings, but two elements of the ring don't necessarily have a unique gcd. If you want a unique gcd for any pair of elements, you need to specialize your commutative ring to a unique factorization domain.
If in addition you want to write your gcd function using the Euclidean algorithm, you need to specialize again to Euclidean domains (of which polynomials and power series are an example).
The `gcd` function in the Haskell base library operators on Integral types, which are the programmatic representation of Euclidean domains, so I would argue that it is "general enough".