ExpressionComplementaryCommutative
com.phasmidsoftware.number.expression.expr.ExpressionComplementaryCommutative
object ExpressionComplementaryCommutative extends CommutativeExtractor[Expression, Expression]
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
- Self type
Members list
In this article