1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel math multiline 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. }
19 { $values n: integer str: string }
20 { $description Converts a number to its upper-case Roman numeral equivalent. }
21 { $notes The range for this word is 1-3999, inclusive. }
31 { $values str: string n: integer }
32 { $description Converts a Roman numeral to an integer. }
33 { $notes The range for this word is i-mmmcmxcix, inclusive. }
35 [=[ USING: prettyprint roman ;
41 { >roman >ROMAN roman> } related-words
44 { $values x: string y: string z: string }
45 { $description Adds two Roman numerals. }
54 { $values x: string y: string z: string }
55 { $description Subtracts two Roman numerals. }
63 { roman+ roman- } related-words
66 { $values x: string y: string z: string }
67 { $description Multiplies two Roman numerals. }
70 "ii" "iii" roman* print
76 { $values x: string y: string z: string }
77 { $description Computes the integer division of two Roman numerals. }
80 "v" "iv" roman/i print
86 { $values x: string y: string z: string w: string }
87 { $description Computes the quotient and remainder of two Roman numerals. }
89 [=[ USING: kernel io prettyprint roman ;
90 "v" "iv" roman/mod [ print ] bi@
95 { roman* roman/i roman/mod } related-words
98 { $description A parsing word that reads the next token and converts it to an integer. }
100 [=[ USING: prettyprint roman ;
106 ARTICLE: "roman" "Roman numerals"
107 The { $vocab-link "roman" } vocabulary can convert numbers to and from the
108 Roman numeral system and can perform arithmetic given Roman numerals as input.
110 A parsing word for literal Roman numerals:
111 { $subsections POSTPONE: ROMAN: }
113 Converting to Roman numerals:
119 Converting Roman numerals to integers:
120 { $subsections roman> }
122 Roman numeral arithmetic: