Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Rosetta PGA-TRAM

by eyepopslikeamosquito (Canon)
on Jun 13, 2009 at 11:48 UTC ( #771219=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    for my $r (@testdata) {
      print "$r: ", roman_to_dec($r), "\n";
    }
    
  2. or download this
    XLII: 42
    LXIX: 69
    mi: 1001
    
  3. or download this
      sub roman_to_dec {
        my $t = 0;
    ...
        }
        return $t;
      }
    
  4. or download this
    def roman_to_dec(r, __rtoa = dict(M=1000, D=500, C=100, L=50, X=10, V=
    +5, I=1) ):
      return reduce( lambda t,n: t+n-t%n*2, (__rtoa[c] for c in r.upper())
    + )
    ...
    testdata = [ "XLII", "LXIX", "mi" ]
    for r in testdata:
      print r, ":", roman_to_dec(r)
    
  5. or download this
    {-# OPTIONS_GHC -fglasgow-exts -Wall #-}
    
    ...
    main :: IO ()
    main = do
      putStrLn $ (concat $ intersperse "\n" (map (\c -> (myshow roman_to_d
    +ec c)) testdata))
    
  6. or download this
    #include <cctype>
    #include <iostream>
    ...
      }
      return 0;
    }
    
  7. or download this
    // Note: there are less than 256 initializers in this table;
    // the uninitialized ones are guaranteed by ANSI C to be
    ...
    {
      return t+urtoa(c)-t%urtoa(c)*2;
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://771219]
Approved by Old_Gray_Bear
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (16)
As of 2015-07-01 17:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (12 votes), past polls