2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								! Copyright (C) 2008 Doug Coleman. 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								! See http://factorcode.org/license.txt for BSD license. 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-27 20:55:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								USING:  help.markup  help.syntax  kernel  math  strings  ;
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								IN:  roman 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  >roman 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values { "n"  "an integer"  } { "str"  "a string"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Converts a number to its lower-case Roman Numeral equivalent."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $notes "The range for this word is 1-3999, inclusive."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: io roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "56 >roman print" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "lvi" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  >ROMAN 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values { "n"  "an integer"  } { "str"  "a string"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Converts a number to its upper-case Roman numeral equivalent."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $notes "The range for this word is 1-3999, inclusive."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: io roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "56 >ROMAN print" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "LVI" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  roman> 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $values { "str"  "a string"  } { "n"  "an integer"  } }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Converts a Roman numeral to an integer."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $notes "The range for this word is i-mmmcmxcix, inclusive."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: prettyprint roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "\"lvi\" roman> ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "56" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ >roman >ROMAN roman> } related-words
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  roman+ 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-27 20:55:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values { "string"  string  } { "string"  string  } { "string"  string  } }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Adds two Roman numerals."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: io roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "\"v\" \"v\" roman+ print" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "x" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  roman- 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-27 20:55:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values { "string"  string  } { "string"  string  } { "string"  string  } }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Subtracts two Roman numerals."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: io roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "\"x\" \"v\" roman- print" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "v" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ roman+ roman- } related-words
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  roman* 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-27 20:55:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values { "string"  string  } { "string"  string  } { "string"  string  } }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Multiplies two Roman numerals."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: io roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "\"ii\" \"iii\" roman* print" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "vi" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  roman/i 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-27 20:55:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values { "string"  string  } { "string"  string  } { "string"  string  } }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Computes the integer division of two Roman numerals."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: io roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "\"v\" \"iv\" roman/i print" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "i" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  roman/mod 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-27 20:55:34 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								{ $values { "string"  string  } { "string"  string  } { "string"  string  } { "string"  string  } }
							 
						 
					
						
							
								
									
										
										
										
											2007-09-20 18:09:08 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $description "Computes the quotient and remainder of two Roman numerals."  }
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: kernel io roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "\"v\" \"iv\" roman/mod [ print ] bi@" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "i\ni" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ roman* roman/i roman/mod } related-words
							 
						 
					
						
							
								
									
										
										
										
											2008-10-21 21:30:26 -04:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								HELP:  ROMAN: 
							 
						 
					
						
							
								
									
										
										
										
											2008-11-11 14:02:51 -05:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								{ $description "A parsing word that reads the next token and converts it to an integer."  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $examples 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    { $example "USING: prettyprint roman ;" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "ROMAN: v ." 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								               "5" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								ARTICLE: "roman"  "Roman numerals" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"A parsing word for literal Roman numerals:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection POSTPONE:  ROMAN:  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"Converting to Roman numerals:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection >roman }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection >ROMAN }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"Converting Roman numerals to integers:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection roman> }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								"Roman numeral arithmetic:" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection roman+ }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection roman- }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection roman* }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection roman/i }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								{ $subsection roman/mod } ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								ABOUT: "roman"