SymExpr 1.1 released
2016-05-22 Filed in:
Tech LibrarySymExpr is a generic Ada package that allow you some manipulation of "symbolic expressions."
https://launchpad.net/symexpr/+downloadFrom
Riccardo BernardiniThe expressions handled by SymExpr have the usual form with the four operations (+, -, * and /), the two unary operators (+ and -),
function calls, variables and parenthesis. The package is a generic package parameterized by the type of the "values" used in the expressions (called "scalars" in the code), so you can have expressions of floats, of integers, but also of dates (my case), complexes, and so on...
* You can create new expressions by parsing strings
X := Parse("foo+(bar-3)*max(bar, foo)") * You can build expressions using constructors and operators, for
example
X := Variable("x"); Y := X*X - 2*X + 1; * You can replace variables with scalars or other expressions, for
example,
-- Replace every occurence of "x" in Y with 42 U := Replace(Y, "x", 42); -- Makes V equal to (X*X)*(X*X) - 2*(X*X) + 1 V := Replace(Y, "x", X*X); * You can evaluate an expression without variables to a scalar.
For example, to plot a graph of Y you could use
for I in -10..10 loop Plot(I, Eval(Replace(Y, "x", I))); end loop;Tags: RegExpr