Post Reply 
[SOLVED] DSRN (dog slow roman numerals)
06-12-2014, 09:17 PM
Post: #14
RE: DSRN (dog slow roman numerals)
Yet another variant without using a subroutine:
Code:
\<< \-> n
  \<<
    {
      { ""      n }
      { "M"  1000 }
      { "CM"  900 }
      { "D"   500 }
      { "CD"  400 }
      { "C"   100 }
      { "XC"   90 }
      { "L"    50 }
      { "XL"   40 }
      { "X"    10 }
      { "IX"    9 }
      { "V"     5 }
      { "IV"    4 }
      { "I"     1 }
    }
    \<<
      + OBJ\-> DROP
      \-> r k
      \<<
        WHILE DUP k \>=
        REPEAT
          k - SWAP
          r + SWAP
        END
        2 \->LIST
      \>>
    \>>
    STREAM HEAD
  \>>
\>>
But I doubt that it will be faster with all that creating and destroying of lists.

Cheers
Thomas

PS: I tried using DOLIST but I failed. However I noticed something I didn't know:
{ 1 2 3 }
1
\<< DUP \>>
DOLIST

This produces:
{ 1 1 2 2 3 3 }

Whatever the program produces will be added to the list. I thought this will lead to:
1
2
3
{ 1 2 3 }
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: DSRN (dog slow roman numerals) - HP67 - 06-11-2014, 07:06 PM
RE: DSRN (dog slow roman numerals) - HP67 - 06-12-2014, 11:44 AM
RE: DSRN (dog slow roman numerals) - HP67 - 06-12-2014, 04:49 PM
RE: DSRN (dog slow roman numerals) - HP67 - 06-15-2014, 12:02 PM
RE: DSRN (dog slow roman numerals) - HP67 - 06-16-2014, 06:09 AM
RE: DSRN (dog slow roman numerals) - HP67 - 06-12-2014, 05:46 PM
RE: DSRN (dog slow roman numerals) - Thomas Klemm - 06-12-2014 09:17 PM



User(s) browsing this thread: 1 Guest(s)