Given a multiplication node of nthRoots (with the same root) will evaluate the nthRoot of each child as a substep e.g. nthRoot(2) * nthRoot(x^2) -> nthRoot(2) * x
513714
function evaluateNthRootForChildren(node) {
  const newNode = clone(node);

  const substeps = [];
  for (let i = 0; i < newNode.args.length; i++) {
    const child = newNode.args[i];
    const childNodeStatus = nthRoot(child);
    if (childNodeStatus.hasChanged()) {
      newNode.args[i] = childNodeStatus.newNode;
      substeps.push(Node.Status.childChanged(newNode, childNodeStatus, i));
    }
  }

  if (substeps.length === 0) {
    return Node.Status.noChange(node);
  }
  else if (substeps.length === 1) {
    return substeps[0];
  }
  else {
    return Node.Status.nodeChanged(
      ChangeTypes.EVALUATE_DISTRIBUTED_NTH_ROOT, node, newNode, true, substeps);
  }
}
908832
private void swap(Node n, Node root) {
        // assert this.root == root;

        Node nLeftChild = n.o_c;
        if (root.o_c == n) {
            if (n.y_s == root) {
                // n is left child and no right sibling
                n.o_c = root;
                root.y_s = n;
            } else {
                // n is left child and has right sibling
                root.y_s = n.y_s;
                root.y_s.y_s = n;
                n.o_c = root;
            }
        } else {
            // n is right child
            root.o_c.y_s = root;
            n.o_c = root.o_c;
            root.y_s = n;
        }
        n.y_s = null;

        // hang children
        root.o_c = nLeftChild;
        if (nLeftChild != null) {
            if (nLeftChild.y_s == n) {
                nLeftChild.y_s = root;
            } else {
                nLeftChild.y_s.y_s = root;
            }
        }
        this.root = n;
    }
604791
def calcFnWeight(node):
    ''''''
    stack = [node]
    count = 0
    while len(stack) > 0:
        node = stack.pop()
        children = [x for x in ast.iter_child_nodes(node)]
        count += len(children)
        stack = stack + children
    return count
1346633
function(node, ignoreSelfAndKids) {
    function nextSiblingEl(n) {
      do {
        n = n.nextSibling;
      } while (n && n.nodeType !== n.ELEMENT_NODE);
      return n;
    }
    // First check for kids if those aren't being ignored
    if (!ignoreSelfAndKids && node.children[0]) {
      return node.children[0];
    }
    // Then for siblings...
    var next = nextSiblingEl(node);
    if (next) {
      return next;
    }
    // And finally, move up the parent chain *and* find a sibling
    // (because this is depth-first traversal, we will have already
    // seen the parent nodes themselves).
    do {
      node = node.parentNode;
      if (node)
        next = nextSiblingEl(node);
    } while (node && !next);
    return node && next;
  }
68715
def visit_Subscript(self, node: ast.Subscript) -> Any:
        """"""
        value = self.visit(node=node.value)
        a_slice = self.visit(node=node.slice)

        result = value[a_slice]

        self.recomputed_values[node] = result
        return result
352938
def xstep(self):
        
        """

        ngsit = 0
        gsrrs = np.inf
        YU = self.Y - self.U
        SYU = self.S + YU[..., -1]
        YU[..., -1] = 0.0
        ATYU = self.cnst_AT(YU)
        while gsrrs > self.opt['GSTol'] and ngsit < self.opt['MaxGSIter']:
            self.X = self.GaussSeidelStep(
                SYU, self.X, ATYU, 1.0, self.lcw, 1.0)
            gsrrs = sl.rrs(
                self.cnst_AT(self.cnst_A(self.X)),
                self.cnst_AT(self.cnst_c() - self.cnst_B(self.Y) - self.U)
            )
            ngsit += 1

        self.xs = (ngsit, gsrrs)
1047287
function tfootNodes(ast) {
  var nodes = [];
  var tfoot;

  for (var i = 0; i < ast.nodes.length; i++) {
    var node = ast.nodes[i];
    if (node.type === 'tfoot') {
      tfoot = node.nodes;
    } else {
      nodes.push(node);
    }
  }

  if (tfoot) {
    var tbody = util.firstOfType(ast.nodes, 'tbody');
    if (tbody) {
      var len = tfoot.length;
      var idx = -1;
      while (++idx < len) {
        var tok = tfoot[idx];
        define(tok, 'parent', tbody);
        tbody.nodes.push(tok);
      }
    }
  }

  ast.nodes = nodes;
  return ast;
}
1247906
def xstep(self):
        
        """

        ngsit = 0
        gsrrs = np.inf
        while gsrrs > self.opt['GSTol'] and ngsit < self.opt['MaxGSIter']:
            self.X = self.GaussSeidelStep(self.S, self.X,
                                          self.cnst_AT(self.Y-self.U),
                                          self.rho, self.lcw, self.Wdf2)
            gsrrs = sl.rrs(
                self.rho*self.cnst_AT(self.cnst_A(self.X)) +
                self.Wdf2*self.X, self.Wdf2*self.S +
                self.rho*self.cnst_AT(self.Y - self.U))
            ngsit += 1

        self.xs = (ngsit, gsrrs)
611236
function findChildContainingNode(root, node) {
  const parentNode = node.parentNode;
  return parentNode === root ?
    node :
    findChildContainingNode(root, parentNode);
}
211726
function nthRootConstant(node) {
  let newNode = clone(node);
  const radicandNode = getRadicandNode(node);
  const rootNode = getRootNode(node);

  if (Negative.isNegative(radicandNode)) {
    return Node.Status.noChange(node);
  }
  else if (!Node.Type.isConstant(rootNode) || Negative.isNegative(rootNode)) {
    return Node.Status.noChange(node);
  }

  const radicandValue = parseFloat(radicandNode.value);
  const rootValue = parseFloat(rootNode.value);
  const nthRootValue = math.nthRoot(radicandValue, rootValue);
  // Perfect root e.g. nthRoot(4, 2) = 2
  if (nthRootValue % 1 === 0) {
    newNode = Node.Creator.constant(nthRootValue);
    return Node.Status.nodeChanged(
      ChangeTypes.NTH_ROOT_VALUE, node, newNode);
  }
  // Try to find if we can simplify by finding factors that can be
  // pulled out of the radical
  else {
    // convert the number into the product of its prime factors
    const factors = ConstantFactors.getPrimeFactors(radicandValue);
    if (factors.length > 1) {
      let substeps = [];
      const factorNodes = factors.map(Node.Creator.constant);

      newNode.args[0] = Node.Creator.operator('*', factorNodes);
      substeps.push(Node.Status.nodeChanged(
          ChangeTypes.FACTOR_INTO_PRIMES, node, newNode));

      // run nthRoot on the new node
      const nodeStatus = nthRootMultiplication(newNode);
      if (nodeStatus.hasChanged()) {
        substeps = substeps.concat(nodeStatus.substeps);
        newNode = nodeStatus.newNode;

        return Node.Status.nodeChanged(
          ChangeTypes.NTH_ROOT_VALUE, node, newNode, true, substeps);
      }
    }
  }

  return Node.Status.noChange(node);
}
71999
def visit_subscript(self, node, parent):
        """"""
        context = self._get_context(node)
        newnode = nodes.Subscript(
            ctx=context, lineno=node.lineno, col_offset=node.col_offset, parent=parent
        )
        newnode.postinit(
            self.visit(node.value, newnode), self.visit(node.slice, newnode)
        )
        return newnode
142151
def children_sum( self, children,node ):
        """"""
        return sum( [self.value(value,node) for value in children] )
1025666
def infix(self, node, children):
        ''
        _, expr1, operator, expr2, _ = children
        return operator(expr1, expr2)
862979
function nthLastChild(node,type) {
    var node = node.lastChild;
    return (!node || checkNth(node, type))? node:nthPrev(node, type);
  }
244962
private float getDepScore(DependencyTree t1, DependencyTree t2, int depth){
		float score = 0.0f;
		float modify = getDepthModify(depth);
		if(modify == 0)
			return score;
		
		double sScore = getWordScore(t1, t2);
        if (sScore != 0)
            score += modify * sScore;
        else
            score += factor * modify * getTagScore(t1, t2);
		
		for(int i = 0; i < t1.leftChilds.size(); i++)
			for(int j = 0; j < t2.leftChilds.size(); j++)
				score += getDepScore(t1.leftChilds.get(i), t2.leftChilds.get(j), depth+1);
		
//		for(int i = 0; i < t1.leftChilds.size(); i++)
//			for(int j = 0; j < t2.rightChilds.size(); j++)
//				score += getDepScore(t1.leftChilds.get(i), t2.rightChilds.get(j), depth+1);
//		
//		for(int i = 0; i < t1.rightChilds.size(); i++)
//			for(int j = 0; j < t2.leftChilds.size(); j++)
//				score += getDepScore(t1.rightChilds.get(i), t2.leftChilds.get(j), depth+1);
		
		for(int i = 0; i < t1.rightChilds.size(); i++)
			for(int j = 0; j < t2.rightChilds.size(); j++)
				score += getDepScore(t1.rightChilds.get(i), t2.rightChilds.get(j), depth+1);
		
		return score;
	}
245071
def Subscript(index_node):
    """"""
    return Node(syms.trailer, [Leaf(token.LBRACE, u"["),
                               index_node,
                               Leaf(token.RBRACE, u"]")])
924512
function parentInorder(n, x) {
  if(n <= 0) {
    return -1
  }
  var r = rootInorder(n)
  if(x > r) {
    var q = parentInorder(n-r-1, x-r-1)
    if(q < 0) {
      return r
    } else {
      return q + r + 1
    }
  } else if(x === r) {
    return -1
  }
  var q =  parentInorder(r, x)
  if(q < 0) {
    return r
  }
  return q
}