Roman numerals/Encode: Difference between revisions

m (→‎{{header|Forth}}: add note that Forth example does not return a string)
Line 737:
 
=={{header|Forth}}==
<lang forth>: vector create ( n -- ) 0 do , loop
{{incorrect|Forth|Does not return a string}}
does> ( n -- ) swap cells + @ execute ;
 
<lang forth>: vector create ( n -- ) 0 do , loop
does> ( n -- ) swap cells + @ execute ;
 
\ these are ( numerals -- numerals )
: .I dup c@ emitC, ;
: .V dup 1 + c@ emitC, ;
: .X dup 2 + c@ emitC, ;
 
\ these are ( numerals -- )
Line 756 ⟶ 753:
:noname .I .I .I drop ;
:noname .I .I drop ;
:noname .I drop ;
' drop \ 0 : no output
10 vector .digit
 
: roman-rec ( numerals n -- )
: 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= if ." EX LIMITO!" exit then
: .roman ( n -- )
HERE SWAP
dup 0 4000 within 0= if ." EX LIMITO!" exit then
s" IVXLCDM" drop swap roman-rec ;</lang>
HERE OVER - ;</lang>
 
=={{header|Fortran}}==
Anonymous user