Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: Adding 2 + 2

by Juerd (Abbot)
on Dec 21, 2001 at 16:30 UTC ( #133743=note: print w/ replies, xml ) Need Help??


in reply to Re: Adding 2 + 2
in thread Adding 2 + 2

A very creative solution :)
Be sure to check out Roman if you didn't know it already. It can convert roman numbers both ways, and checks if your roman input is valid.

use Roman; $calc = "II + II"; $calc =~ s/([MDCLXVI]+)/isroman($1) ? arabic($1) : $1/; print eval $calc;

2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$


Comment on Re: Re: Adding 2 + 2
Select or Download Code
Re: Re: Re: Adding 2 + 2
by mr_mischief (Monsignor) on Jan 02, 2002 at 20:22 UTC
    Thanks for the review and the suggestion.

    I knew Roman was available, but it didn't feel right to use it for this. I felt it was more in the spirit of the thread to go overboard and develop the needed tools specifically for the node. I'm actually a bit surprised it took someone posting a hand-crafted Roman to Arabic numeral conversion before someone gave an example using the module. It was one of the first twists on the problem that popped into my deranged mind.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://133743]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2014-12-28 06:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls