public function testCall() { $sum = function ($one, $two) { return $one + $two; }; $this->assertEqualsMatrix([[11, Std::call($sum, 5, 6)], [[1, 2, 4, 5, 6], Std::call('array_merge', [1, 2], [4, 5], [6])]]); }
/** * Combine all the elements in the traversable using a combining operation. * * @param callable|Closure $closure * @param mixed $initial * * @return mixed */ public function foldlWithKey(callable $closure, $initial) { $accumulator = $initial; foreach ($this->value as $key => $value) { $accumulator = Std::call($closure, $accumulator, $value, $key); } return $accumulator; }
/** * @param ApplyInterface $other * * @return ApplyInterface */ public function ap(ApplyInterface $other) { $this->assertSameType($other); $result = []; Std::poll(function ($ii) use(&$result, &$other) { Std::poll(function ($jj) use(&$result, &$other, $ii) { $result[] = Std::call($this->value[$ii], $other->value[$jj]); }, count($other->value)); }, count($this->value)); return $result; }
/** * Execute the transform. * * @param array $input * * @return array */ public function run(array $input) { return Std::call($this->inner, $input); }