1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel math strings ;
7 { $values { "n" integer } { "str" string } }
8 { $description "Converts a number to its lower-case Roman Numeral equivalent." }
9 { $notes "The range for this word is 1-3999, inclusive." }
11 { $example "USING: io roman ;"
18 { $values { "n" integer } { "str" string } }
19 { $description "Converts a number to its upper-case Roman numeral equivalent." }
20 { $notes "The range for this word is 1-3999, inclusive." }
22 { $example "USING: io roman ;"
29 { $values { "str" string } { "n" integer } }
30 { $description "Converts a Roman numeral to an integer." }
31 { $notes "The range for this word is i-mmmcmxcix, inclusive." }
33 { $example "USING: prettyprint roman ;"
39 { >roman >ROMAN roman> } related-words
42 { $values { "x" string } { "y" string } { "z" string } }
43 { $description "Adds two Roman numerals." }
45 { $example "USING: io roman ;"
46 "\"v\" \"v\" roman+ print"
52 { $values { "x" string } { "y" string } { "z" string } }
53 { $description "Subtracts two Roman numerals." }
55 { $example "USING: io roman ;"
56 "\"x\" \"v\" roman- print"
61 { roman+ roman- } related-words
64 { $values { "x" string } { "y" string } { "z" string } }
65 { $description "Multiplies two Roman numerals." }
67 { $example "USING: io roman ;"
68 "\"ii\" \"iii\" roman* print"
74 { $values { "x" string } { "y" string } { "z" string } }
75 { $description "Computes the integer division of two Roman numerals." }
77 { $example "USING: io roman ;"
78 "\"v\" \"iv\" roman/i print"
84 { $values { "x" string } { "y" string } { "z" string } { "w" string } }
85 { $description "Computes the quotient and remainder of two Roman numerals." }
87 { $example "USING: kernel io roman ;"
88 "\"v\" \"iv\" roman/mod [ print ] bi@"
93 { roman* roman/i roman/mod } related-words
96 { $description "A parsing word that reads the next token and converts it to an integer." }
98 { $example "USING: prettyprint roman ;"
104 ARTICLE: "roman" "Roman numerals"
105 "The " { $vocab-link "roman" } " vocabulary can convert numbers to and from the Roman numeral system and can perform arithmetic given Roman numerals as input." $nl
106 "A parsing word for literal Roman numerals:"
107 { $subsections POSTPONE: ROMAN: }
108 "Converting to Roman numerals:"
113 "Converting Roman numerals to integers:"
114 { $subsections roman> }
115 "Roman numeral arithmetic:"