lib/simplifyExpression/basicsSearch/reduceMultiplicationByZero.js
// reduce the node to 0. Returns a Node.Status object.
reduce the node to 0.
reduce the node to 0 .
function reduceMultiplicationByZero(node) {
  if (node.op !== '*') {
    return Node.Status.noChange(node);
  }
  const zeroIndex = node.args.findIndex(arg => {
    if (Node.Type.isConstant(arg) && arg.value === '0') {
      return true;
    }
    if (Node.PolynomialTerm.isPolynomialTerm(arg)) {
      const polyTerm = new Node.PolynomialTerm(arg);
      return polyTerm.getCoeffValue() === 0;
    }
    return false;
  });
  if (zeroIndex >= 0) {
    const newNode = Node.Creator.constant(0);
    return Node.Status.nodeChanged(
      ChangeTypes.MULTIPLY_BY_ZERO, node, newNode);
  }
  else {
    return Node.Status.noChange(node);
  }
}
function reduceMultiplicationByZero ( node ) { if ( node . op !== '*' ) { return Node . Status . noChange ( node ) ; } const zeroIndex = node . args . findIndex ( arg => { if ( Node . Type . isConstant ( arg ) && arg . value === '0' ) { return true ; } if ( Node . PolynomialTerm . isPolynomialTerm ( arg ) ) { const polyTerm = new Node . PolynomialTerm ( arg ) ; return polyTerm . getCoeffValue ( ) === 0 ; } return false ; } ) ; if ( zeroIndex >= 0 ) { const newNode = Node . Creator . constant ( 0 ) ; return Node . Status . nodeChanged ( ChangeTypes . MULTIPLY_BY_ZERO , node , newNode ) ; } else { return Node . Status . noChange ( node ) ; } }
reduce the node to 0.
reduce the node to 0 .
// reduce to just the 0 node