Parser.pl - Macro-based fronted to the MathObjects system.

From WeBWorK

Jump to: navigation


NAME

Parser.pl - Macro-based fronted to the MathObjects system.

MACROS

Formula

        Formula("formula");

The main way to get a MathObject Formula object (an equation that depends on one or more variables).

Compute

        Compute("formula"[, var=>value, ...]);

Compute the value of a formula and return a MathObject appropriate to its value. Set the object so that the correct answer will be shown as in the given string rather than by its usual stringification. (I.e., the stringified version of the formula when reduceConstants, reduceConstantFunctions, and showExtraParens are set to 0 is used.)

If the value is a Formula and any var=>value pairs are specified, then the formula will be evaluated using the given variable values. E.g.,

        $x = Compute("x+3",x=>2)

will produce the equivalent of $x = Real(5). In this case, the original parsed formula will be saved in the object's original_formula field, and can be obtained by

        $x->{original_formula};

if needed later in the problem.

If the formula is contstant-valued, Compute() will return the value of the formula rather than the formula itself. Again, in this case, the original can be obtained from the original_formula property.

Context

        Context();
        Context($name);
        Context($context);

Set or get the current context. When a name is given, the context with that name is selected as the current context. When a context reference is provided, that context is set as the current one. In all three cases, the current context (after setting) is returned.