コード例 #1
0
ファイル: StdTest.php プロジェクト: chromabits/nucleus
 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])]]);
 }
コード例 #2
0
 /**
  * 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;
 }
コード例 #3
0
 /**
  * @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;
 }
コード例 #4
0
 /**
  * Execute the transform.
  *
  * @param array $input
  *
  * @return array
  */
 public function run(array $input)
 {
     return Std::call($this->inner, $input);
 }