<?xml version="1.0" encoding="windows-1252"?>
<node id="971630" title="Re: Rosetta PGA-TRAM" created="2012-05-21 10:37:41" updated="2012-05-21 10:37:41">
<type id="11">
note</type>
<author id="298378">
Arunbear</author>
<data>
<field name="doctext">
A nearly verbatim translation to Ruby:
&lt;code&gt;
$rtoa = { :M=&gt;1000, :D=&gt;500, :C=&gt;100, :L=&gt;50, :X=&gt;10, :V=&gt;5, :I=&gt;1 }

def roman_to_dec(roman)
  roman.split(//).map { |c| $rtoa[c.upcase.to_sym] }.reduce { |t, n | t+n-t%n*2  }
end

%w[ XLII LXIX mi ].each { |r| puts roman_to_dec r }
&lt;/code&gt;
</field>
<field name="root_node">
771219</field>
<field name="parent_node">
771219</field>
</data>
</node>
