Task

Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero.



In Roman numerals:

 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC
 2008 is written as 2000=MM, 8=VIII; or MMVIII
 1666 uses each Roman symbol in descending order: MDCLXVI


: vector create ( n -- ) 0 do , loop  does>  ( n -- ) swap cells + @ execute ; 
\ these are ( numerals -- numerals )
: ,I  dup c@ C, ;  : ,V  dup 1 + c@ C, ;  : ,X  dup 2 + c@ C, ; 
 
\ these are ( numerals -- )
:noname  ,I ,X     drop ;   :noname  ,V ,I ,I ,I  drop ;   :noname  ,V ,I ,I  drop ;  
:noname  ,V ,I     drop ;   :noname  ,V           drop ;   :noname  ,I ,V     drop ;
:noname  ,I ,I ,I  drop ;   :noname  ,I ,I        drop ;   :noname  ,I        drop ;  
' drop ( 0 : no output )  10 vector ,digit 
 
: roman-rec ( numerals n -- )  10 /mod dup if >r over 2 + r> recurse else drop then ,digit ; 
: roman ( n -- c-addr u )  
  dup 0 4000 within 0= abort" EX LIMITO!" 
  HERE SWAP  s" IVXLCDM" drop swap roman-rec  HERE OVER - ;
 
1999 roman type     \ MCMXCIX 
  25 roman type     \ XXV
 944 roman type     \ CMXLIV