Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Rosetta PGA-TRAM

by Arunbear (Parson)
on Jun 13, 2009 at 18:35 UTC ( #771280=note: print w/replies, xml ) Need Help??

in reply to Rosetta PGA-TRAM

A Scala version (basically similar in form to the Perl/Python versions):
val rtoa = Map('M' -> 1000, 'D' -> 500, 'C' -> 100, 'L' -> 50, 'X' -> +10, 'V' -> 5, 'I' -> 1) def romanToDec(roman: String) : Int = => rtoa(c.toUpperCase)).reduceLeft((x, y) => x + y - x + % y * 2) val testData = List("XLII", "LXIX", "mi") for(r <- testData) println(r + ": " + romanToDec(r))

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://771280]
[Corion]: jthebarg: There is the switch keyword if you want that, but maybe a dispatch table is closer.
[Corion]: If by "case" you meant "case-insensitive ", see fc, uc and lc and perlop on the /i flag ;)
Corion waves to virtualsue
[virtualsue]: I have made a post for the first time in ... years
[marto]: hey virtualsue!
Eily thought about Neko Case first, something might be wrong with my brain's wiring
[virtualsue]: I recommended dbic-migration even though I am having trouble with it this week. It might be my fault.
[ambrus]: wow! I haven't seen you here for a long time, virtualsue
virtualsue waves back
[Eily]: it would have been 2 years in 2 weeks actually. And welcome back virtualsue :)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (14)
As of 2017-09-26 13:46 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (295 votes). Check out past polls.