Apolyton Archive  |  Preserved copy of the Apolyton Civilization Site and its forums as they stood in September 2005. Read-only; nothing here can be posted to or replied to.  |  Forum index |  About this archive |  The 1998–2001 UBB forums
Today on Apolyton WARDELL INTERVIEW PROMO A.C.S. HISTORY CHAPTER 4 GET CIV4 /w FREE PLUS! A.C.S. PHOTO GALLERY GET A.O.M. V1.1
Apolyton Civilization Forums
main| civ2| civ3| civ4| smac| ctp2| ron| moo3| galciv| galciv2| alt| about|
ApolytonPLUS | register | search | faq | new posts | pm (-/-) | upload | members
hall of fame new! | civgroups | civgroups news | interviews | the column | radio | chat | directory | news | store | PLUS
Apolyton Civilization Forums : Powered by vBulletin version 2.0.3 Apolyton Civilization Forums > Miscellaneous > Off-Topic > Script to replace "a^b" in an expression with "pow(a,b)"
Show a Printable Version | Email This Page to Someone! | Receive updates to this thread | Report this to Apolyton news!
20.Sep: FOURTH CHAPTER IN `HISTORY OF...` PUBLISHED
13.Sep: NEWS ON THE FLY
06.Sep: APOLYTON DONATES TO HURRICANE RELIEF

bottom of page
   - CIVILIZATION 3 $9.99 - CIVILIZATION 2 from $6.95 - CIVILIZATION 2 from $4.25 - ALPHA CENTAURI + ALIEN CROSSFIRE (laptop collection) from $19.99 - ALPHA CENTAURI PC $9.99 -->
Author
Thread   
Pages (2): [ 1   2   ]
< Last Thread     Next Thread > Post New Thread     Post A Reply
Provost Harrison is offline Provost Harrison
Emperor
The farce is strong with this one.
Feb 2000
time: 05:22
  Old Post 26-02-2005 05:08
Edit/Delete Message Reply w/Quote
#31 Report this post to a moderator
Full PM-box? Change here!

Believe it or not, I can figure out how I would get it to do it in BBC Assembler (6502 processor) but not in some modern fancy language

BlackCat is offline BlackCat
Warlord

Jul 2004
time: 05:22
  Old Post 26-02-2005 06:38
Edit/Delete Message Reply w/Quote
#32 Report this post to a moderator
Browse Apolyton AD-FREE

quote:
Originally posted by Provost Harrison
Believe it or not, I can figure out how I would get it to do it in BBC Assembler (6502 processor) but not in some modern fancy language


If you could do it on a Z80 running CPM, I maybe will have some respect for you

Urban Ranger is offline Urban Ranger
Apolyton Duke of Off-Topic

Donate to the Red Cross
The City State of Noosphere, CPA special envoy
May 1999
time: 13:22
  Old Post 26-02-2005 06:52
Edit/Delete Message Reply w/Quote
#33 Report this post to a moderator
Browse Apolyton AD-FREE

Looks like a neat little problem for writing a clever regex.

Mercator is offline Mercator
King
Sorekara no Nanimo
Jan 1970
time: 06:22
  Old Post 26-02-2005 07:05 Visit Mercator's homepage!
Edit/Delete Message Reply w/Quote
#34 Report this post to a moderator
Browse Apolyton AD-FREE

quote:
Originally posted by Ramo
Mercator, I just installed Active Perl. Now, how would I run your script?


I'm assuming your formulas are in a text file (or multiple files), with a formula preferably on one line (or at least not having a line break in between one such power construction)...

The quickest way is to simply type it in on the command-line:

code:
perl -pi.bak -e"s/(\w+(?:\([^()]*\))?)\^(\w*(?:\(.*?\))?)/pow($1,$2)/g;" your_formula_filename(s)


That'll perform a global search/replace and will even create backups, with an added .bak extension.


If you more conveniently want to save it as a perl script (which does exactly the same), so you can use it later. Create a file that looks like this:

code:
#!/Perl/bin/perl.exe -pi.bak s/(\w+(?:\([^()]*\))?)\^(\w*(?:\(.*?\))?)/pow($1,$2)/g;


Make sure the first line matches your actual Perl path.
You'd call that script like this:
code:
perl the_perl_script formula_file1 formula_file2


*cough* And I'm a bit late with this, but you could achieve the same with a text editor supporting Perl regular expressions, like Arachnophilia. In that case you'd simply open the file and replace all:
code:
(\w+(?:\([^()]*\))?)\^(\w*(?:\(.*?\))?)

by:
code:
pow($1,$2)

alva is offline alva
Emperor
Republic of Flanders
Sep 2001
time: 06:22
  Old Post 26-02-2005 11:08
Edit/Delete Message Reply w/Quote
#35 Report this post to a moderator
Support Apolyton or Terrorists Win

quote:
Originally posted by BlackCat
Forget about doing that automaticlly - it's a waste of time. Also drop using MS tools - they sucks - use vi (no, this is not std MS bashing - I work on both unix and MS platforms, and vi is the winner).

Bleh, Visual studio.

quote:
And to think, that was going be the name of my next DL...




I dare you.

Provost Harrison is offline Provost Harrison
Emperor
The farce is strong with this one.
Feb 2000
time: 05:22
  Old Post 26-02-2005 16:38
Edit/Delete Message Reply w/Quote
#36 Report this post to a moderator
Support Apolyton or Terrorists Win

quote:
Originally posted by BlackCat


If you could do it on a Z80 running CPM, I maybe will have some respect for you


I don't know the specific instruction set, but I know roughly how I would do it

 
Pages (2): [ 1   2   ]
< Last Thread     Next Thread > Post New Thread     Post A Reply
All times are GMT. The time now is 05:22.
Apolyton Time is 00:22.
    top of page
Rate This Thread:
Forum Jump:
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
 




Contact Us - Apolyton Civilization Site - Support Us!

Building a better Apolyton through better information. Click here and take our poll!
Non-US visitors, click here!

Powered by: vBulletin Version 2.0.3
Copyright ©2000, 2001, Jelsoft Enterprises Limited.

Page generated in 0.0417 seconds (89.15% PHP - 10.85% MySQL) with 30 queries
Page Loading Time:

Support Apolyton: Amazon USA | Amazon UK | Amazon DE | Amazon FR |
Support Apolyton and get FREE PLUS, Buy from Chips&Bits: Galactic Civilizations | Galactic Civilizations: Deluxe Edition | Call to Power 2 | Civilization: The Boardgame | GURPS/ Alpha Centauri | Alpha Centauri | Civilization IV | Civilization III: Complete |


Front Page | Civilization IV | Civilization III | Civilization II | Call to Power II | Alpha Centauri | Master of Orion III
Rise of Nations | Galactic Civilizations | Galactic Civilizations II | Misc
Alt.Civs | Civ I | C:CtP I | About | News | Directory | Apolyton Store | Forums | Chat | Columns | Interviews | Newsletter
Scenario League | CSC | Clash of Civs | Spanish Site | CtP Maps | Cradle of Civ | WesW's Ctp1/2 Site | Civ3 Haven

apolyton.net | apolyton.com | civilization2.net | civilization3.net | civilization4.net | civilizationiv.info | calltopower.net | galciv.net | galciv2.net | moo3.net