Term

com.phasmidsoftware.number.expression.parse.ExpressionParser.Term
case class Term(f: ExpressionParser.this.Factor, fs: List[String ExpressionParser.this.~ ExpressionParser.this.Factor]) extends Tokens

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.

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

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

def value: Try[Expression]

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.

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product