Represents a Term as part of an expression, consisting of a leading Factor followed by a list of pairs containing an operator (String) and a subsequent Factor.
Value parameters
f
The leading Factor in the term.
fs
A list of operator-factor pairs, where each pair contains a string operator and a Factor.
Attributes
Constructor
Creates a Term with a leading Factor and a sequence of operator-factor pairs.
Evaluates the value of a String ~ Factor pair based on the operator provided in the String.
Evaluates the value of a String ~ Factor pair based on the operator provided in the String.
The function supports two operators:
"*": Multiplication, directly evaluates the factor's value.
"/": Division, applies the division operation using the one element and the factor's value.
If an unsupported operator is encountered, it returns a failure with a ParseException.
Value parameters
t
a pair consisting of an operator (String) and a Factor
Attributes
Returns
a Try[Expression] containing the evaluated result if the operator is supported and the factor can be evaluated, or a failure if the operator is unsupported or the evaluation fails
Evaluates the expression and returns the result wrapped in a Try. The Try indicates whether the evaluation was successful (Success) or resulted in an error (Failure).
Evaluates the expression and returns the result wrapped in a Try. The Try indicates whether the evaluation was successful (Success) or resulted in an error (Failure).
Attributes
Returns
a Try[Expression] containing either the result of the evaluation or an error.