Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Roman-numerals-Encode/Retro/roman-numerals-encode.retro
Normal file
24
Task/Roman-numerals-Encode/Retro/roman-numerals-encode.retro
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
: vector ( ...n"- )
|
||||
here [ &, times ] dip : .data ` swap ` + ` @ ` do ` ; ;
|
||||
: .I dup @ ^buffer'add ;
|
||||
: .V dup 1 + @ ^buffer'add ;
|
||||
: .X dup 2 + @ ^buffer'add ;
|
||||
|
||||
[ .I .X drop ]
|
||||
[ .V .I .I .I drop ]
|
||||
[ .V .I .I drop ]
|
||||
[ .V .I drop ]
|
||||
[ .V drop ]
|
||||
[ .I .V drop ]
|
||||
[ .I .I .I drop ]
|
||||
[ .I .I drop ]
|
||||
[ .I drop ]
|
||||
&drop
|
||||
10 vector .digit
|
||||
|
||||
: record ( an- )
|
||||
10 /mod dup [ [ over 2 + ] dip record ] &drop if .digit ;
|
||||
: toRoman ( n-a )
|
||||
here ^buffer'set
|
||||
dup 1 3999 within 0 =
|
||||
[ "EX LIMITO!\n" ] [ "IVXLCDM" swap record here ] if ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue