Value (also called MathObjects) are intelligent versions of standard mathematical objects. They 'know' how to produce string or TeX or perl representations of themselves. They also 'know' how to compare themselves to student responses -- in other words they contain their own answer evaluators (response evaluators). The standard operators like +, -, *, <, ==, >, etc, all work with them (when they make sense), so that you can use these MathObjects in a natural way. The comparisons like equality are "fuzzy", meaning that two items are equal when they are "close enough" (by tolerances that are set in the current Context).
The following are list objects, meaning that they involve delimiters (parentheses) of some type. They get overridden in lib/Parser/Context.pm
lists => {
'Point' => {open => '(', close => ')'},
'Vector' => {open => '<', close => '>'},
'Matrix' => {open => '[', close => ']'},
'List' => {open => '(', close => ')'},
'Set' => {open => '{', close => '}'},
};
The following context flags are set:
For vectors:
ijk => 0, # print vectors as <...>
For strings:
allowEmptyStrings => 1,
infiniteWord => 'infinity',
For intervals and unions:
ignoreEndpointTypes => 0,
reduceSets => 1,
reduceSetsForComparison => 1,
reduceUnions => 1,
reduceUnionsForComparison => 1,
For fuzzy reals:
useFuzzyReals => 1,
tolerance => 1E-4,
tolType => 'relative',
zeroLevel => 1E-14,
zeroLevelTol => 1E-12,
tolTruncation => 1,
tolExtraDigits => 1,
For Formulas:
limits => [-2,2],
num_points => 5,
granularity => 1000,
resolution => undef,
max_adapt => 1E8,
checkUndefinedPoints => 0,
max_undefined => undef,
Precedence of the various types (They will be promoted upward automatically when needed)
'Number' => 0,
'Real' => 1,
'Infinity' => 2,
'Complex' => 3,
'Point' => 4,
'Vector' => 5,
'Matrix' => 6,
'List' => 7,
'Interval' => 8,
'Set' => 9,
'Union' => 10,
'String' => 11,
'Formula' => 12,
'special' => 20,
Get the value of a flag from the object itself, or from the equation that created the object (if any), or from the AnswerHash for the object (if it is being used as the source for an answer checker), or from the object's context, or from the current context, or use the given default, whichever is found first.
Usage: $mathObj->getFlag("showTypeWarnings"); $mathObj->getFlag("showTypeWarnings",1); # default is second parameter
Usage: Value->subclassed($self,"classMatch")
if $self has the method 'classMath' and 'Value' has the method 'classMatch' and the reference to these methods don't agree then the method 'classMatch' has been subclassed.
Usage:
Value->Package(name[,noerror]])
Returns the package name for the specificied Value object class (as specified by the context's {value} hash, or "Value::name").
Usage:
Value::makeValue(45);
This will create a Real mathObject and convert non-Value objects to Values, if possible
Usage:
$mathObj->showClass();
This returns a printable version of the class of an object (used primarily in error messages)
Usage:
$mathObj->showType();
This will return a printable version of the type of an object (the class and type are not the same. For example a Formula-class object can be of type Number)
Return a string describing a value's type
Get a string describing a value's type, and convert the value to a Value object (if needed)
Convert a list of values to a list of formulas (called by Parser::Value)
Convert a list of values (and open and close parens) to a formula whose type is the list type associated with the parens.
A shortcut for new()
that creates an instance of the object, but doesn't do the error checking. We assume the data are already known to be good.
Easy method for setting parameters of an object (returns a copy with the new values set, but the copy is not a deep copy.)
Return a copy with the specified fields removed
Return the hash data as an array of key=>value pairs
Copy attributes that are not already in the current object from the given objects. (Used by binary operators to make sure the result inherits the values from the two terms.)
The list of fields NOT to inherit. Use the default list plus any specified explicitly in the object itself. Subclasses can override and return additional fields, if necessary.
Return a type structure for the item (includes name, length of vectors, and so on)
Get an element from a point, vector, matrix, or list
Promote an operand to the same precedence as the current object
Return the operators in the correct order
Return the operators in the correct order, and promote the other value, if needed.
Handle a binary operator, promoting the object types as needed, and then calling the main method
Compare the values of the objects
Compare the values as strings
Copy flags from the parent object to its children (recursively).
Usage:
$mathObj->stringify();
Produces text string or TeX output depending on context.
Usage:
$mathObj->string()
produce a string representation of the object (as opposed to stringify, which can produce TeX or string versions)
Usage:
$mathObj->TeX()
produce TeX prepresentation of the object
Usage:
Value->Error("We're sorry...");
OR
$mathObject->Error("We're still sorry...");
Report an error and die. This can be used within custom answer checkers to report errors during the check, or when sub-classing a MathObject to report error conditions.
Try to locate the line and file where the error occurred