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).
#############################################################
#
# Initialize the context-- flags set
#
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::makeValue(45);
Will create a Real mathObject.
#
# Convert non-Value objects to Values, if possible
#
Usage: TEXT( $mathObj -> showClass() );
Will print the class of the MathObject
#
# Get a printable version of the class of an object
# (used primarily in error messages)
#
Usage: TEXT( $mathObj -> showType() );
Will print the class of the MathObject
#
# Get 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)
#
#
# Generate the various output formats
# (can be replaced by sub-classes)
#
Usage: TEXT($mathObj); or TEXT( $mathObj->stringify() ) ;
Produces text string or TeX output depending on context
Context()->texStrings;
Context()->normalStrings;
called automatically when object is called in a string 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.
#