 PRIVATE>
 
 : >roman ( n -- str )
-    dup roman-range-check [ (>roman) ] "" make ;
+    roman-range-check
+    roman-values roman-digits [
+        [ /mod swap ] dip <repetition> concat
+    ] 2map "" concat-as nip ;
 
 : >ROMAN ( n -- str ) >roman >upper ;
 
 : roman> ( str -- n )
-    >lower [ roman<= ] monotonic-split [ (roman>) ] sigma ;
+    >lower [ roman>= ] monotonic-split [ (roman>) ] sigma ;
 
 <PRIVATE
 

PRIVATE>

<<
SYNTAX: ROMAN-OP:
    scan-word [ name>> "roman" prepend create-in ] keep
    1quotation '[ _ binary-roman-op ]
    dup infer [ in>> ] [ out>> ] bi
    [ "string" <repetition> ] bi@ <effect> define-declared ;
>>

ROMAN-OP: +

! 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 quotations sequences sequences.private
splitting.monotonic stack-checker strings unicode.case words ;
IN: roman

<PRIVATE
