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.
Combines the string representation of a tuple containing a string and a Factor, formatting it with a newline and the provided indentation level.
Combines the string representation of a tuple containing a string and a Factor, formatting it with a newline and the provided indentation level.
Value parameters
i
The indentation level to be used for formatting.
t
A tuple containing a string (t._1) and a Factor (t._2).
Attributes
Returns
A formatted string that combines the first element of the tuple with the string representation of the Factor, separated by a newline, with the appropriate indentation.
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[T] 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
Computes the result of folding a sequence of inputs using the given operations map2 and times. This method starts with the initial value f.value and iteratively combines it with each result of applying factorVal on elements of fs.
Computes the result of folding a sequence of inputs using the given operations map2 and times. This method starts with the initial value f.value and iteratively combines it with each result of applying factorVal on elements of fs.
Attributes
Returns
A Try[T] representing the result of the fold operation or the encountered failure.