clean up duplication

db4
Doug Coleman 2009-03-27 20:04:05 -05:00
parent 5138842c83
commit 9b74a99a8e
1 changed files with 7 additions and 7 deletions

View 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>