packages/solver/lib/simplifyExpression/stepThrough.js
function stepThrough(node, debug=false) {
  if (debug) {
    // eslint-disable-next-line
    console.log('\n\nSimplifying: ' + print(node, false, true));
  }

  if(checks.hasUnsupportedNodes(node)) {
    return [];
  }

  let nodeStatus;
  const steps = [];

  const originalExpressionStr = print(node);
  const MAX_STEP_COUNT = 20;
  let iters = 0;

  // Now, step through the math expression until nothing changes
  nodeStatus = step(node);
  while (nodeStatus.hasChanged()) {
    if (debug) {
      logSteps(nodeStatus);
    }
    steps.push(removeUnnecessaryParensInStep(nodeStatus));
    const nextNode = Status.resetChangeGroups(nodeStatus.newNode);
    nodeStatus = step(nextNode);
    if (iters++ === MAX_STEP_COUNT) {
      // eslint-disable-next-line
      console.error('Math error: Potential infinite loop for expression: ' +
                    originalExpressionStr + ', returning no steps');
      return [];
    }
  }

  return steps;
}
function stepThrough(node, debug=false) {
  if (debug) {
    // eslint-disable-next-line
    console.log('\n\nSimplifying: ' + print(node, false, true));
  }

  if(checks.hasUnsupportedNodes(node)) {
    return [];
  }

  let nodeStatus;
  const steps = [];

  const originalExpressionStr = print(node);
  const MAX_STEP_COUNT = 20;
  let iters = 0;

  // Now, step through the math expression until nothing changes
  nodeStatus = step(node);
  while (nodeStatus.hasChanged()) {
    if (debug) {
      logSteps(nodeStatus);
    }
    steps.push(removeUnnecessaryParensInStep(nodeStatus));
    const nextNode = Status.resetChangeGroups(nodeStatus.newNode);
    nodeStatus = step(nextNode);
    if (iters++ === MAX_STEP_COUNT) {
      // eslint-disable-next-line
      console.error('Math error: Potential infinite loop for expression: ' +
                    originalExpressionStr + ', returning no steps');
      return [];
    }
  }

  return steps;
}
function stepThrough ( node , debug = false ) { if ( debug ) { // eslint-disable-next-line console . log ( '\n\nSimplifying: ' + print ( node , false , true ) ) ; } if ( checks . hasUnsupportedNodes ( node ) ) { return [ ] ; } let nodeStatus ; const steps = [ ] ; const originalExpressionStr = print ( node ) ; const MAX_STEP_COUNT = 20 ; let iters = 0 ; // Now, step through the math expression until nothing changes nodeStatus = step ( node ) ; while ( nodeStatus . hasChanged ( ) ) { if ( debug ) { logSteps ( nodeStatus ) ; } steps . push ( removeUnnecessaryParensInStep ( nodeStatus ) ) ; const nextNode = Status . resetChangeGroups ( nodeStatus . newNode ) ; nodeStatus = step ( nextNode ) ; if ( iters ++ === MAX_STEP_COUNT ) { // eslint-disable-next-line console . error ( 'Math error: Potential infinite loop for expression: ' + originalExpressionStr + ', returning no steps' ) ; return [ ] ; } } return steps ; }
Given a mathjs expression node, steps through simplifying the expression. Returns a list of details about each step.
Given a mathjs expression node steps through simplifying the expression . Returns a list of details about each step .