ExpressionComplementaryCommutative

com.phasmidsoftware.number.expression.expr.ExpressionComplementaryCommutative

Extractor object for handling negation expressions in a commutative manner. Matches pairs of expressions where one is a plain Expression and the other is its negation UniFunction(x, Negate).

extractLeft excludes negated expressions so that the two roles are mutually exclusive. This prevents the swap path in CommutativeExtractor from binding a to a negated expression and producing a spurious a == b match.

With this fix the commented-out shorthand in structuralMatcher works correctly:

 case ProductExpression(ExpressionComplementaryCommutative(a, b)) if a == b =>
   minusXSquared(a)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Inherited methods

def unapply(pair: (Expression, Expression)): Option[(Expression, Expression)]

Unapply method that tries both orderings on a tuple. First tries (extractLeft(left), extractRight(right)), then tries (extractLeft(right), extractRight(left)).

Unapply method that tries both orderings on a tuple. First tries (extractLeft(left), extractRight(right)), then tries (extractLeft(right), extractRight(left)).

Attributes

Inherited from:
CommutativeExtractor