Term

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

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

def factorShow(t: String ArithmeticParser.this.~ ArithmeticParser.this.Factor, i: Int): String

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.

def factorVal(t: String ArithmeticParser.this.~ ArithmeticParser.this.Factor): Try[ArithmeticParser.this.T]

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

def show(i: Int): String

Constructs and returns a formatted string representation of the term and its components based on the provided input.

Constructs and returns a formatted string representation of the term and its components based on the provided input.

Value parameters

i

the integer input used to determine the formatting and content of the output string

Attributes

Returns

a formatted string representation of the term and its components

def value: Try[ArithmeticParser.this.T]

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.

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