Constructor
new Application(operator, …operands)
Construct a new Application instance from the given operator (requried)
and list of operands (zero or more). For example, to construct $f(x)$,
call new Application(f,x)
, where we assume that f
and x
are
already defined elsewhere (perhaps as Symbols). Or to
construct $17.2-p$, call new Application(m,s,p)
, where m
is the
subtraction operator, s
is the constant $17.2$ and p
is the
variable $p$. Each of these three (m
,s
,p
) would most likely be
an instance of the Symbol class.
Note that while it is possible later to remove children from an Application until it has none, this is likely to result in the members of this class malfunctioning or throwing errors. Clients should not remove the final child of an Application; that is not supported.
Parameters
-
operator
Expression
The function or operation that is being applied to the operands. This argument is required, and must be an Expression.
-
operands
Expression
<repeatable>
The list of zero or more operands to which the operator is being applied. This may be an empty list, but each entry on the list must be an Expression.
Throws
If any of the arguments is not an Expression, this constructor throws an error.
Source
Classes
Methods
operands() → {Expression}
Applications store their operator and operands as children, in the same order as in LISP S-expressions, that is, with the operator as the first child, and the operands in order therafter (if there are any). Thus this function returns the list of all but the first child of this object, when considering it as an Expression (or more generally as a MathConcept).
If the children have not been manipulated since construction of the object, then this is the original array of operands given at construction time. If children have been added or removed since then, the new array of children (after the first) is assumed to be the list of operands.
Returns
-
Expression
the operands to which this Application instance applies its operator
Source
operator() → {Expression}
Applications store their operator and operands as children, in the same order as in LISP S-expressions, that is, with the operator as the first child, and the operands in order therafter (if there are any). Thus this function returns the first child of this object, when considering it as an Expression (or more generally as a MathConcept).
If the children have not been manipulated since construction of the object, then this is the original operator given at construction time. If a new first child has been inserted since then, or the old first child removed, the new first child is assumed to be the operator.
Returns
-
Expression
the operator that this Application instance applies to its operands