1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel math ;
7 { $values { "n" "an integer" } { "str" "a 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" "an integer" } { "str" "a 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" "a string" } { "n" "an 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 { "str1" "a string" } { "str2" "a string" } { "str3" "a string" } }
43 { $description "Adds two Roman numerals." }
45 { $example "USING: io roman ;"
46 "\"v\" \"v\" roman+ print"
52 { $values { "str1" "a string" } { "str2" "a string" } { "str3" "a string" } }
53 { $description "Subtracts two Roman numerals." }
55 { $example "USING: io roman ;"
56 "\"x\" \"v\" roman- print"
61 { roman+ roman- } related-words
64 { $values { "str1" "a string" } { "str2" "a string" } { "str3" "a string" } }
65 { $description "Multiplies two Roman numerals." }
67 { $example "USING: io roman ;"
68 "\"ii\" \"iii\" roman* print"
74 { $values { "str1" "a string" } { "str2" "a string" } { "str3" "a string" } }
75 { $description "Computes the integer division of two Roman numerals." }
77 { $example "USING: io roman ;"
78 "\"v\" \"iv\" roman/i print"
84 { $values { "str1" "a string" } { "str2" "a string" } { "str3" "a string" } { "str4" "a 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 { $subsection POSTPONE: ROMAN: }
108 "Converting to Roman numerals:"
109 { $subsection >roman }
110 { $subsection >ROMAN }
111 "Converting Roman numerals to integers:"
112 { $subsection roman> }
113 "Roman numeral arithmetic:"
114 { $subsection roman+ }
115 { $subsection roman- }
116 { $subsection roman* }
117 { $subsection roman/i }
118 { $subsection roman/mod } ;