lib/checks/canMultiplyLikeTermConstantNodes.js
// The node can either be on form c^n or c, as long as c is the same for all.
The node can either be on form c^n or c, as long as c is the same for all.
The node can either be on form c^n or c as long as c is the same for all .
function canMultiplyLikeTermConstantNodes(node) {
  if (!Node.Type.isOperator(node) || node.op !== '*') {
    return false;
  }
  const args = node.args;
  if (!args.every(n => ConstantOrPowerTerm.isConstantOrConstantPower(n))) {
    return false;
  }
  if (args.every(arg => !Node.Type.isOperator(arg, '^'))) {
    return false;
  }
  const constantTermBaseList = args.map(n => ConstantOrPowerTerm.getBaseNode(n));
  const firstTerm = constantTermBaseList[0];
  const restTerms = constantTermBaseList.slice(1);
  return restTerms.every(term => firstTerm.value === term.value);
}
function canMultiplyLikeTermConstantNodes ( node ) { if ( ! Node . Type . isOperator ( node ) || node . op !== '*' ) { return false ; } const args = node . args ; if ( ! args . every ( n => ConstantOrPowerTerm . isConstantOrConstantPower ( n ) ) ) { return false ; } if ( args . every ( arg => ! Node . Type . isOperator ( arg , '^' ) ) ) { return false ; } const constantTermBaseList = args . map ( n => ConstantOrPowerTerm . getBaseNode ( n ) ) ; const firstTerm = constantTermBaseList [ 0 ] ; const restTerms = constantTermBaseList . slice ( 1 ) ; return restTerms . every ( term => firstTerm . value === term . value ) ; }
The node can either be on form c^n or c, as long as c is the same for all.
The node can either be on form c^n or c as long as c is the same for all .
// if none of the terms have exponents, return false here, // else e.g. 6*6 will become 6^1 * 6^1 => 6^2 // they're considered like terms if they have the same base value