ParserFunction: Utilities for parsing and evaluating mathematical expressions.
ParserFunction provides utilities for parsing and evaluating mathematical expressions.
The central parsing function in this package is stringToExpr
, which parses a string-expression
(e.g. "3*x+2") and returns a Maybe expression tree of type Expr (e.g. Just (Add (Mul (Num 3.0) (Var 'x')) (Num 2.0))).
This type is suitable for performing symbolic logic. Expressions can then be evaluated using the function evaluate
(e.g. evaluate
(fromAscList [("x",2)]) (Add (Mul (Num 3.0) (Var 'x'))) (Num 2.0) would give 8.0).
If you wish to evaluate a string-expression without any intermediate symbolic logic operations, simply use the function
evaluateExpression
(e.g. evaluateExpression
"3*x+2" [('x',4)] gives 14.0). More examples of these functions can be found
by viewing the source code for this package.
Downloads
- ParserFunction-0.0.6.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
Versions [RSS] | 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.1.0 |
---|---|
Dependencies | base (<6), containers, parsec [details] |
License | BSD-3-Clause |
Author | Enzo Haussecker |
Maintainer | ehaussecker@gmail.com |
Category | Parsing |
Uploaded | by EnzoHaussecker at 2012-02-07T22:33:12Z |
Distributions | NixOS:0.1.0 |
Reverse Dependencies | 1 direct, 0 indirect [details] |
Downloads | 8317 total (9 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs uploaded by user Build status unknown [no reports yet] |