Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Arcane
Newbie


Joined: 19 Apr 2003
Posts: 1
Location: Australia

PostPosted: Sat Apr 19, 2003 2:43 am   

Problem: Alphabetic numbers to real Numerals?
 
I was wondering if any of the zMud gurus' would be able to write an efficient method for converting fully written alphabetic numbers into their numeral counterparts so that mathematical operations can be performed.

The MUD I play on only uses numbers in the following format:

one, two, three..., twenty-four, twenty-five...

In order to use them in calculations I need a method of converting the alphabetic into numerals. The routine would only be required to convert up to ninety-nine (99) as I am yet to see any instances of any higher numbers in an alphabetic format.

It wouldn't be necessary to use substitution in the text output as all the calculations would be performed behind the scenes for component counting/buying etc and informational purposes.

Thanks in advance =)

Arcane

zMud 6.56
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Apr 19, 2003 3:34 am   
 
Here's the quickest way to get what you want:

#variable AlphaNumbers {one|two|three|four|...}
#trigger {(%x) apples minus (%x) apples} {#math Answer {%ismember(%1,@AlphaNumbers) - %ismember(%2,@AlphaNumbers)}}

Since ZMud already has exactly the function you want (in a roundabout way), all you need to do is ensure you have a complete and in-order list of alpha numbers to refer to.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Apr 19, 2003 3:15 pm   
 
#CLASS {NumberConvert}
#ALIAS ConvertNumber {#IF (@Factors="") {#ADDKEY Factors @TempExportFactorList;#UNVAR TempExportFactorList};#LOOPDB @Factors {NWord=%replace(@NWord,%key,%val)};NWord=%eval(@NWord)}
#VAR Factors {}
#VAR TempExportFactorList {one=1|two=2|twen=2|three=3|thir=3|four=4|for=4|five=5|fif=5|six=6|seven=7|eight=8|nine=9|ten=10|eleven=11|twelve=12|teen=+10|ty=*10|-=+}
#VAR NWord {} {}
#CLASS 0

To use it just put the word into NWord and call ConvertNumber. It should be able to handle hundreds, thousands, millions, billions, etc by adding the appropiate factor. The Factors variable is actually a record var, but my experience says they don't transfer well in the forums hence the temp list.
Reply with quote
megamog75
Enchanter


Joined: 20 Nov 2002
Posts: 627
Location: USA

PostPosted: Tue Apr 22, 2003 10:49 pm   
 
here is a nice simple one i came up with.

#CLASS {numwords}
#VAR numwords {one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|ninteen|twenty|twenty-one|twenty-two|twenty-three|twenty-four|twenty-five|twenty-six|twent-seven|twenty-eight|twenty-nine|thirty|thirty-one|thirty-two|thirty-three}
#ONINPUT {(*) (%d) (*)} {%1 %item(@numwords,%2) %3}
#CLASS 0

Zmud has no limits....

megamog75
Keeper of the only printable help files for Zmud.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Apr 23, 2003 12:20 am   
 
ZMud does too have limits. ZMud doesn't do windows, it can't feed your pets, and it doesn't make Julienne french fries!

li'l shmoe of Dragon's Gate MUD
Reply with quote
Palmer
Novice


Joined: 21 Mar 2003
Posts: 38
Location: USA

PostPosted: Wed Apr 23, 2003 9:12 am   
 
Gee, Arcane, you wouldn't be bending DW rules would you? ;P
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net