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
Announcement
Collapse
No announcement yet.
Script to replace "a^b" in an expression with "pow(a,b)"
Collapse
X
-
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 languageWith or without religion, you would have good people doing good things and evil people doing evil things. But for good people to do evil things, that takes religion.
Steven Weinberg
Comment
-
Looks like a neat little problem for writing a clever regex.(\__/) 07/07/1937 - Never forget
(='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
(")_(") "Starting the fire from within."
Comment
-
Originally posted by Ramo
Mercator, I just installed Active Perl. Now, how would I run your script?
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)
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;
You'd call that script like this:
Code:perl the_perl_script formula_file1 formula_file2
Code:(\w+(?:\([^()]*\))?)\^(\w*(?:\(.*?\))?)
Code:pow($1,$2)
Comment
-
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).
And to think, that was going be the name of my next DL...
I dare you.Is God willing to prevent evil, but not able? Then he is not omnipotent. Is he able, but not willing? Then he is malevolent. Is he both able and willing? Then whence cometh evil? Is he neither able nor willing?
Then why call him God? - Epicurus
Comment
-
Originally posted by BlackCat
If you could do it on a Z80 running CPM, I maybe will have some respect for youSpeaking of Erith:
"It's not twinned with anywhere, but it does have a suicide pact with Dagenham" - Linda Smith
Comment
Comment