eval

Evaluates a simple (does not contain functions) arithmetic expression.

  1. string eval(string exp, string op)
  2. string eval(string exp)
    static pure
    string
    eval
    (
    string exp
    )

Parameters

exp string

The arithmetic expression to be evaluated.

Return Value

Type: string

The evaluated arithmetic expression.

Examples

auto result = eval("(5 + 3) * 2");
assert(result == "16");

auto expr = "3 * (4 + 2) / 3";
auto simplifiedExpr = eval(expr);
assert(simplifiedExpr == "6");

Meta