3 ms·
Small correction; with the most common implementation of Euclid's algorithm the compiler would infer gcd :: Integral a => a -> a -> a since writing Euclid
by crntaylor 14y ago
Small correction; with the most common implementation of Euclid's algorithm the compiler would infer
gcd :: Integral a => a -> a -> a
since writing Euclid's algorithm requires using `mod` or `rem`, both of which only work for integral types (NB. there are many integral types beside ints, for example polynomials, formal power series and gaussian integers).
The Integral class captures the mathematical idea of a Euclidean domain, which can loosely be thought of as "number systems for which the Euclidean algorithm works".