About the GCD operator, the Haskell Report currently says: "gcd x y is the greatest integer that divides both x and y. lcm x y is the smallest positive integer that both x and y divide." Why does 'lcm' say 'positive' while 'gcd' does not? What is gcd -3 -6 Presumably 3, not -3. You could say that is obvious, since 3 > -3. So I propose to add "positive" to the gcd spec: gcd x y is the greatest POSITIVE integer that divides both x and y. I don't think that changes the specification in fact, but experience has led me to always check these things! Simon
"Simon" == Simon Peyton-Jones <simonpj@microsoft.com> writes:
Simon> gcd x y is the greatest POSITIVE integer that divides Simon> both x and y. Simon> I don't think that changes the specification in fact, but Simon> experience has led me to always check these things! I find it confusing to read a definition which contains redundant information. Instead, I'd suggest to add something like: "Note: this number is always positive" Cheers -- Christoph Herrmann
On Tue, Dec 11, 2001 at 11:06:28AM +0100, Ch. A. Herrmann wrote:
"Simon" == Simon Peyton-Jones <simonpj@microsoft.com> writes: Simon> gcd x y is the greatest POSITIVE integer that divides Simon> both x and y.
Simon> I don't think that changes the specification in fact, but Simon> experience has led me to always check these things!
I find it confusing to read a definition which contains redundant information. Instead, I'd suggest to add something like:
"Note: this number is always positive"
yeah. I strongly agree with this wording. precision without confusion is a really nice feature in specifications. mainly i know that if i were to read the redundant version I would invariably spend several brain cycles trying to figure out why it isn't redundant, only to conclude that it is. John -- --------------------------------------------------------------------------- John Meacham - California Institute of Technology, Alum. - john@repetae.net ---------------------------------------------------------------------------
Simon> gcd x y is the greatest POSITIVE integer that divides Simon> both x and y.
I find it confusing to read a definition which contains redundant information. Instead, I'd suggest to add something like:
"Note: this number is always positive"
Or, perhaps easier on the eye, "gcd x y is the greatest (positive) integer that divides both x and y." --KW 8-) -- Keith Wansbrough <kw217@cl.cam.ac.uk> http://www.cl.cam.ac.uk/users/kw217/ University of Cambridge Computer Laboratory.
participants (4)
-
Ch. A. Herrmann -
John Meacham -
Keith Wansbrough -
Simon Peyton-Jones