Roman numerals/Decode: Difference between revisions

Content added Content deleted
m (→‎mapAccumR: Qualified import of Data.Map.Strict, tidied)
m (→‎{{header|Tailspin}}: Mark the counting numbers as such)
Line 6,228:
=={{header|Tailspin}}==
<lang tailspin>
def digits: [(M:1000"1"), (CM:900"1"), (D:500"1"), (CD:400"1"), (C:100"1"), (XC:90"1"), (L:50"1"), (XL:40"1"), (X:10"1"), (IX:9"1"), (V:5"1"), (IV:4"1"), (I:1"1")];
composer decodeRoman
@: 1;
[ <digit>* ] -> \(@: 0; $... -> @: $@ + $; $@ !\)
rule digit: <value>* (@: $@ + 1;)
rule value: <='$digits($@)::key;'> -> $digits($@)::value
end decodeRoman