]> gitweb.factorcode.org Git - factor.git/commitdiff
clean up duplication
authorDoug Coleman <erg@jobim.local>
Sat, 28 Mar 2009 01:04:05 +0000 (20:04 -0500)
committerDoug Coleman <erg@jobim.local>
Sat, 28 Mar 2009 01:04:05 +0000 (20:04 -0500)
basis/roman/roman.factor

index f1913239924497fff2517793445c061ba875824d..66fb3b302a492cfb7176446001e974c215a14a2d 100644 (file)
@@ -20,11 +20,14 @@ ERROR: roman-range-error n ;
 : roman-range-check ( n -- )
     dup 1 3999 between? [ drop ] [ roman-range-error ] if ;
 
+: roman-digit-index ( ch -- n )
+    1string roman-digits index ; inline
+
 : roman<= ( ch1 ch2 -- ? )
-    [ 1string roman-digits index ] bi@ >= ;
+    [ roman-digit-index ] bi@ >= ;
 
 : roman>n ( ch -- n )
-    1string roman-digits index roman-values nth ;
+    roman-digit-index roman-values nth ;
 
 : (>roman) ( n -- )
     roman-values roman-digits [
@@ -32,11 +35,8 @@ ERROR: roman-range-error n ;
     ] 2each drop ;
 
 : (roman>) ( seq -- n )
-    [ [ roman>n ] map ] [ all-eq? ] bi [
-        sum
-    ] [
-        first2 swap -
-    ] if ;
+    [ [ roman>n ] map ] [ all-eq? ] bi
+    [ sum ] [ first2 swap - ] if ;
 
 PRIVATE>