]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/roman/roman.factor
Fixes #2966
[factor.git] / basis / roman / roman.factor
index 588166829ad7142128a217f04b8a66b0bf9a7cd9..edff040dacf15da26baae8b9f84bc7b8a0c80b1a 100644 (file)
@@ -1,10 +1,9 @@
 ! Copyright (C) 2007 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs effects fry generalizations
-grouping kernel lexer macros math math.order math.vectors
-namespaces parser effects.parser quotations sequences
-sequences.private splitting.monotonic stack-checker strings
-unicode.case words ;
+! See https://factorcode.org/license.txt for BSD license.
+USING: accessors combinators.smart effects.parser
+generalizations grouping kernel lexer math math.order
+parser quotations sequences splitting.monotonic strings unicode
+words ;
 IN: roman
 
 <PRIVATE
@@ -23,14 +22,14 @@ ERROR: roman-range-error n ;
 : roman-digit-index ( ch -- n )
     1string roman-digits index ; inline
 
-: roman>= ( ch1 ch2 -- ? )
+: roman-digit>= ( ch1 ch2 -- ? )
     [ roman-digit-index ] bi@ >= ;
 
-: roman>n ( ch -- n )
+: roman-digit-value ( ch -- n )
     roman-digit-index roman-values nth ;
 
-: (roman>) ( seq -- n )
-    [ [ roman>n ] map ] [ all-eq? ] bi
+: roman-value ( seq -- n )
+    [ [ roman-digit-value ] map ] [ all-eq? ] bi
     [ sum ] [ first2 swap - ] if ;
 
 PRIVATE>
@@ -44,7 +43,8 @@ PRIVATE>
 : >ROMAN ( n -- str ) >roman >upper ;
 
 : roman> ( str -- n )
-    >lower [ roman>= ] monotonic-split [ (roman>) ] map-sum ;
+    >lower [ roman-digit>= ] monotonic-split
+    [ roman-value ] map-sum ;
 
 <PRIVATE
 
@@ -57,9 +57,9 @@ PRIVATE>
 <<
 
 SYNTAX: ROMAN-OP:
-    scan-word [ name>> "roman" prepend create-in ] keep
+    scan-word [ name>> "roman" prepend create-word-in ] keep
     1quotation '[ _ binary-roman-op ]
-    complete-effect define-declared ;
+    scan-effect define-declared ;
 
 >>
 
@@ -69,4 +69,4 @@ ROMAN-OP: * ( x y -- z )
 ROMAN-OP: /i ( x y -- z )
 ROMAN-OP: /mod ( x y -- z w )
 
-SYNTAX: ROMAN: scan roman> suffix! ;
+SYNTAX: ROMAN: scan-token roman> suffix! ;