Anonymous user
Roman numerals/Encode: Difference between revisions
→{{header|Forth}}
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 ▼
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@
: .V dup 1 + c@
: .X dup 2 + c@
\ these are ( numerals -- )
Line 756 ⟶ 753:
:noname .I .I .I drop ;
:noname .I .I drop ;
:noname .I drop ;
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 ) ▼
▲: .roman ( n -- )
HERE SWAP
▲ dup 0 4000 within 0= if ." EX LIMITO!" exit then
s" IVXLCDM" drop swap roman-rec
HERE OVER - ;</lang>
=={{header|Fortran}}==
|