public function visitArrayMultiplicationNode(ArrayMultiplicationNode $node) { return $this->_renderNode($this->_indent($this->depth + 1) . '<multiplication type="array">' . PHP_EOL . implode(PHP_EOL, array_map(function (DerivableNodeInterface $child) { $v = new XMLVisitor($this->depth + 2); return $v->visit($child); }, $node->getChildren())) . PHP_EOL . $this->_indent($this->depth + 1) . '</multiplication>'); }
public function visitArrayMultiplicationNode(ArrayMultiplicationNode $node) { foreach ($node->getChildren() as $child) { if ($this->visit($child)) { return true; } } return $this->_evalIsZero($node); }
public function visitArrayMultiplicationNode(ArrayMultiplicationNode $node) { $nodes = []; foreach ($node->getChildren() as $key => $c) { $cpy = $this->copy($node->getChildren()); $cpy[$key] = $this->visit($c); $nodes[] = Tree::mult(...$cpy); } return Tree::add(...$nodes); }
public function visitArrayMultiplicationNode(ArrayMultiplicationNode $node) { $nodes = []; $constant = 1; foreach ($node->getChildren() as $key => $c) { $child = $this->visit($c); if ($this->isZeroVisitor->visit($child)) { return Tree::init(0); } else { if ($this->isConstantVisitor->visit($child)) { $constant *= $this->evaluationVisitor->visit($child); } else { $nodes[] = $child; } } } if ($constant != 1) { array_unshift($nodes, new ConstantNode($constant)); } if (count($nodes) == 1) { return $nodes[0]; } return new ArrayMultiplicationNode(...$nodes); }
public function visitArrayMultiplicationNode(ArrayMultiplicationNode $node) { return array_product(array_map(function (DerivableNodeInterface $child) { return $this->visit($child); }, $node->getChildren())); }