showing Ratios

Doug McIlroy doug at cs.dartmouth.edu
Thu Feb 25 09:54:04 EST 2010


Very minor library change to promote readability of output:
eliminate spaces in the string representation of Ratios.

Currently, a Ratio appears as a pair separated by " % ".
The spaces that flank "%" make for confusing output.
Example:

	[1 % 2,1 % 3,1 % 4,1 % 5,1 % 6]

The spaces suggest that "," binds more tightly than "%".
I claim that

	[1%2,1%3,1%4,1%5,1%6]

is much more readable.  It also saves paper and/or screen area.

I suspect that the spaces came in to make it easier to find
the division point in a lugubrious Ratio like

	123456789%987654321

True enough, but such numbers are too incomprehensible
to get much scrutiny anyway.  I, at least, find that all
I do with Ratios much more complicated than 355%113 is
squirrel them away in tables that only a computer is
likely to read seriously, or edit them into some other
form, e.g. for Sloane's Encyclopedia of Integer Sequences.

Doug McIlroy


More information about the Haskell-prime mailing list