Roman
roman
This collection provides two files:
roman.ss: converts ints to roman numerals and vice versa
_Roman_
_roman_
This collection provides two files:
_roman.ss_: converts ints to roman numerals and vice versa
_roman-test.ss_: unit tests for roman.ss
======================================================================
These functions only handle numbers in the range 1 to 3999 inclusive.
This library is caps-sensitive: "VI" is fine, "Vi", "vI", and "vi"
are not.
A Roman numeral is well-formed iff
* it consists entirely of M, C, D, X, L, I, V, and
* it is valid per the Roman numeral system as defined at
http://en.wikipedia.org/wiki/Roman_numerals.
roman.ss
--------------
> int->roman : (integer-in 1 3999) -> string?
Converts input to its Roman numeral representation.
> roman->int : string? -> (union (integer-in 1 3999) false?)
Converts well-formed Roman numerals to integers.
> summa : roman ... -> roman
Adds arbitrarily many, but not fewer than one, roman numbers.
> productum : roman ... -> roman
Multiplies arbitrarily many, but not fewer than one, roman numbers.
> differentia : roman roman -> roman
Subtracts the second roman from the first.
> quotiens : roman roman -> roman
Computes the quotient of the two numbers.
(quotiens "IV" "II") => "II"
(quotiens "IV" "III") => "I"
> residuum : roman roman -> roman
Computes the remainder of the first roman divided by the second.
(residuum "V" "II") => "I"
> test-all : -> void?
Prints out the functions applied to all numbers in the range. That is,
if you want to verify these functions, you can run this.
EXAMPLES -------------------------------------------------------------
> (int->roman 1121)
"MCXXI"
> (roman->int "MCXXI")
1121
These functions hacked by Adam Shaw on June 12, 2006.
Have a nice, Roman-numeral filled day.