Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Inputting Math Functions

by gaal (Parson)
on Dec 17, 2006 at 18:15 UTC ( #590330=note: print w/replies, xml ) Need Help??

in reply to Inputting Math Functions

The first suggestion would be find out what expressions you want to support. Is it just the four basic arithmetic ops? What representations do you need of numbers (eg., base ten? Scientific notation like 8E6? Rationals? Arbitrary precision reals? Complex numbers?). Do you need precedence to work implicitly (eg., is "32 + 9/5 * x" "32 + ((9/5) * x)"? Or "((32 + 9)/5) * x"? Something else)? Do you need to allow arbitrary functions that you had defined earlier?

Depending on how simple your needs, you may be able to use a simple regular expression to do the parsing for you, or you may need something more involved.

Replies are listed 'Best First'.
Re^2: Inputting Math Functions
by fredopalus (Friar) on Dec 17, 2006 at 18:20 UTC
    Yeah, I would need to work within the set of reals, using transcendental functions as well as polynomials, rationals, etc..
      Then you should use a Real Parser to make sense of your expression. Parse::RecDescent was mentioned and is fine to use, if a little slow. Maybe you want to try this out in Perl 6 Rules though? You'd need Pugs for that, or perhaps stay in Perl 5 and give Pugs::Compiler::Rule a shot.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2022-01-29 14:39 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (74 votes). Check out past polls.