Constructor
new Expression(…children)
Constructs an Expression from the given list of children, which may be empty. All children must also be instances of Expression; those that are not are filtered out.
Parameters
-
children
Expression
<repeatable>
child Expressions to be added to this one (as in the constructors for MathConcept and LogicConcept)
Source
Classes
Methods
getOutermost() → {Expression}
This function walks up the MathConcept hierarchy containing this Expression until it finds an ancestor satisfying isOutermost(), and then it returns that Expression.
Returns
-
Expression
the outermost Expression ancestor of this Expression
Source
isAConclusionIn(ancestor) → {boolean}
Based on the definition given in the conclusions() function, an Expression will be a conclusion in one of its ancestors if all of the following are true.
- it is not marked with the "given" attribute
- its parent is an Environment
- neither that parent nor any other ancestor (up to and including the one specified as parameter) are marked with the "given" attribute
If no ancestor is provided, then the top-level MathConcept ancestor is used instead.
Parameters
-
ancestor
MathConcept
the context in which this query is being made
Returns
-
boolean
whether this expression is a conclusion in the given
ancestor
Source
isOutermost() → {boolean}
If this Expression has an Expression parent, then it is not the outermost expression in the hierarchy. However, if it has a parent that is some other kind of MathConcept or LogicConcept, then it is the outermost Expression in the hierarchy. If it has no parent, it is the outermost.
See
Returns
-
boolean
Whether this expression is the outermost Expression in the MathConcept hierarchy in which it sits
Source
value() → {*}
Many mathematical expressions have standard interpretations. We permit Expression instances to be marked with an attribute indicating that they have a standard interpretation, and what that interpretation is. This function looks for such attributes and applies them, computing the value of the Expression, if it has one, and returning undefined if it does not.
An Expression that has a value will have an attribute whose key is the
string "evaluate as"
and whose value is a string such as "integer"
or "integer base 2"
or "string"
or "ordered pair"
or any of a
wide variety of other ways to evaluate the Expression's content.
It is intended that this list can grow over time, and this function be updated to support new types of simple mathematical values as they are needed. It is not intended that every kind of possible interpretation should show up on this list, but rather just those types that are common/standard across enough of mathematics that they will be used in any kind of mathematics software.
This initial implementation provides support for none of the types of valuation described above, because each is best implemented in one of this class's subclasses (Symbol or Application) instead. A stub is implemented here as a pure virtual method, to guarantee that the function exists for all Expression instances and returns undefined by default.
Returns
-
*
any basic JavaScript value representing this Expression, or undefined if it there is no such value