AtomicExpression

com.phasmidsoftware.number.expression.expr.AtomicExpression
See theAtomicExpression companion trait

Companion object for the AtomicExpression trait. Provides utility methods for working with instances of AtomicExpression.

The unapply method enables pattern matching on AtomicExpression instances, providing an optional Valuable as a result based on the type of the expression. The behavior of this method varies for different subtypes of AtomicExpression, such as Complex, ValueExpression, Literal, Valuable, Noop, and ReducedQuadraticRoot.

Notes:

  • For Complex, the method directly returns the Complex instance as a Valuable.
  • For ValueExpression and Literal, the value of the Valuable is returned, but the name might be discarded during extraction.
  • For Valuable, the method directly returns the Valuable.
  • For ReducedQuadraticRoot, the method attempts to evaluate it "as-is."
  • For Noop, the method returns None.

Considerations:

  • The use of Complex and Valuable directly in the extraction may warrant re-evaluation.
  • The potential loss of the name in ValueExpression and Literal is noted as a trade-off.

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def unapply(arg: AtomicExpression): Option[Valuable]

Extracts an optional Valuable from an AtomicExpression instance based on its type. This method provides a mechanism for pattern matching on subtypes of AtomicExpression, returning a Valuable where applicable.

Extracts an optional Valuable from an AtomicExpression instance based on its type. This method provides a mechanism for pattern matching on subtypes of AtomicExpression, returning a Valuable where applicable.

Value parameters

arg

the AtomicExpression instance from which the Valuable is to be extracted. This can be one of the subtypes such as Complex, ValueExpression, Literal, Valuable, Noop, or ReducedQuadraticRoot.

Attributes

Returns

an Option containing the extracted Valuable if one can be determined based on the type of arg. Returns None if no Valuable can be extracted, e.g., in the case of Noop.