withSimplifying static method

MathNode withSimplifying(
  1. MathNode left,
  2. MathNode right
)

Multiplication with simplification of unary operations

Returns value of either operand if the other operands equals the value of 1

Implementation

static MathNode withSimplifying(MathNode left, MathNode right) {
  if (left == const MathValue(1)) return right;
  if (right == const MathValue(1)) return left;

  return MathOperatorMultiplication(left, right);
}