示例#1
0
 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>');
 }
示例#2
0
 public function visitArrayMultiplicationNode(ArrayMultiplicationNode $node)
 {
     foreach ($node->getChildren() as $child) {
         if ($this->visit($child)) {
             return true;
         }
     }
     return $this->_evalIsZero($node);
 }
示例#3
0
 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);
 }
示例#4
0
 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);
 }
示例#5
0
 public function visitArrayMultiplicationNode(ArrayMultiplicationNode $node)
 {
     return array_product(array_map(function (DerivableNodeInterface $child) {
         return $this->visit($child);
     }, $node->getChildren()));
 }