Exemplo n.º 1
0
Arquivo: Chain.php Projeto: iddqdby/f7
 /**
  * Invoke a value if it is callable.
  *
  * @param array $args optional array of arguments to pass to the optional callable
  * @return Chain the result of the invocation wrapped into a Chain, or empty Chain
  */
 public function invokeArray(array $args = []) : Chain
 {
     return $this->continue(conditionally(is_callable, curry(reverse(call_user_func_array), 2)($args)));
 }
Exemplo n.º 2
0
 /**
  * Find last element of the stream (optionally matched with predicate).
  *
  * This is a closing operation (it calls <code>$this->close()</code> internally).
  *
  * @param callable $predicate the predicate (optional)
  * @return Optional an optional result
  * @see \monad\Stream::close()
  */
 public function findLast(callable $predicate = null) : Optional
 {
     return $this->bindMonad(sequence(curry(reverse(array_reverse))(true), curry(function ($predicate, array $array) {
         return $this->find($predicate, $array);
     }, 2)($predicate), optional));
 }