Roman numerals/Decode: Difference between revisions
Content added Content deleted
(+Java) |
(→Tcl: Added implementation) |
||
Line 94: | Line 94: | ||
2008 |
2008 |
||
1666</pre> |
1666</pre> |
||
=={{header|Tcl}}== |
|||
As long as we assume that we have a valid roman number, this is most easily done by transforming the number into a sum and evaluating the expression: |
|||
<lang tcl>proc fromRoman rnum { |
|||
set map {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+} |
|||
expr [string map $map $rnum]0} |
|||
}</lang> |
|||
=={{header|Zsh}}== |
=={{header|Zsh}}== |
||
<lang zsh>function parseroman () { |
<lang zsh>function parseroman () { |