Created
May 1, 2013 19:55
-
-
Save anonymous/5497871 to your computer and use it in GitHub Desktop.
masakism ROMAN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Test; | |
is to_roman(3), "III", "3 gets converted to III"; | |
sub to_roman (Int $n is copy) { | |
my $printstring; | |
for <M 1000 D 500 C 100 L 50 X 10 V 5 I 1> -> $roman, $decimal { | |
$printstring ~= $roman x $n div +$decimal; | |
$n %= $decimal; | |
} | |
for <DCCCC CM CCCC CD LXXXX XC XXXX XL VIIII IX IIII IV> -> $long, $short { | |
$printstring ~~ s:g/$long/$short/; | |
} | |
say $printstring; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment