]> gitweb.factorcode.org Git - factor.git/blob - basis/roman/roman-docs.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / basis / roman / roman-docs.factor
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 ;
4 IN: roman
5
6 HELP: >roman
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." }
10 { $examples 
11     { $example "USING: io roman ;"
12                "56 >roman print"
13                "lvi"
14     }
15 } ;
16
17 HELP: >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." }
21 { $examples 
22     { $example "USING: io roman ;"
23                "56 >ROMAN print"
24                "LVI"
25     }
26 } ;
27
28 HELP: 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." }
32 { $examples 
33     { $example "USING: prettyprint roman ;"
34                "\"lvi\" roman> ."
35                "56"
36     }
37 } ;
38
39 { >roman >ROMAN roman> } related-words
40
41 HELP: roman+
42 { $values { "string" string } { "string" string } { "string" string } }
43 { $description "Adds two Roman numerals." }
44 { $examples 
45     { $example "USING: io roman ;"
46                "\"v\" \"v\" roman+ print"
47                "x"
48     }
49 } ;
50
51 HELP: roman-
52 { $values { "string" string } { "string" string } { "string" string } }
53 { $description "Subtracts two Roman numerals." }
54 { $examples 
55     { $example "USING: io roman ;"
56                "\"x\" \"v\" roman- print"
57                "v"
58     }
59 } ;
60
61 { roman+ roman- } related-words
62
63 HELP: roman*
64 { $values { "string" string } { "string" string } { "string" string } }
65 { $description "Multiplies two Roman numerals." }
66 { $examples 
67     { $example "USING: io roman ;"
68         "\"ii\" \"iii\" roman* print"
69         "vi"
70     }
71 } ;
72
73 HELP: roman/i
74 { $values { "string" string } { "string" string } { "string" string } }
75 { $description "Computes the integer division of two Roman numerals." }
76 { $examples 
77     { $example "USING: io roman ;"
78         "\"v\" \"iv\" roman/i print"
79         "i"
80     }
81 } ;
82
83 HELP: roman/mod
84 { $values { "string" string } { "string" string } { "string" string } { "string" string } }
85 { $description "Computes the quotient and remainder of two Roman numerals." }
86 { $examples 
87     { $example "USING: kernel io roman ;"
88         "\"v\" \"iv\" roman/mod [ print ] bi@"
89         "i\ni"
90     }
91 } ;
92
93 { roman* roman/i roman/mod } related-words
94
95 HELP: ROMAN:
96 { $description "A parsing word that reads the next token and converts it to an integer." }
97 { $examples 
98     { $example "USING: prettyprint roman ;"
99                "ROMAN: v ."
100                "5"
101     }
102 } ;
103
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 } ;
119
120 ABOUT: "roman"