Returns the composition of a list of functions.

@param callable $function The leftmost function of the composition chain
@param callable $function,... An unlimited list of callables to compose

@return callable
427834
public static function compose(/* $function1, $function2, ... */)
    {
        $functions = func_get_args();

        if (count($functions) === 1) {
            static::validate($functions[0]);
            return $functions[0];
        }

        $firstFunction = array_shift($functions);

        static::validate($firstFunction);

        return function() use($firstFunction, $functions) {

            $partial = call_user_func_array(array('\Functionals\Functionals', 'compose'), $functions);

            return call_user_func($firstFunction, call_user_func_array($partial, func_get_args()));
        };
    }
240568
def compose(*functions):
    

    def _compose2(f, g):  # pylint: disable=invalid-name
        return lambda x: f(g(x))

    return functools.reduce(_compose2, functions, lambda x: x)
247243
public static function lift(callable $function, Left $left) : callable
    {
        return function () use ($function, $left) {
            if (
                array_reduce(
                    func_get_args($function),
                    function (bool $status, Either $val) {
                        return $val->isLeft() ? false : $status;
                    },
                    true
                )
            ) {
                $args = array_map(
                    function (Either $either) {
                        return $either
                            ->orElse(Either::right(null))
                            ->getRight();
                    },
                    func_get_args()
                );

                return self::right(call_user_func($function, ...$args));
            }

            return $left;
        };
    }
359771
public static function getReflection(callable $f)
    {
        if (is_string($f)) {
            if (strpos($f, '::', 1) !== false) {
                return new \ReflectionMethod($f);
            } else {
                return new \ReflectionFunction($f);
            }
        } elseif (is_array($f) && count($f) == 2) {
            return new \ReflectionMethod($f[0], $f[1]);
        } elseif ($f instanceof \Closure) {
            return new \ReflectionFunction($f);
        } elseif (is_object($f) && method_exists($f, '__invoke')) {
            return new \ReflectionMethod($f, '__invoke');
        }
        // if the tests above are exhaustive, we should never hit the next line.
        throw new AnnotationException("Unable to determine callable type.");
    }
1165635
public function addTypePreCallFunction($type, callable $function)
    {
        if (isset($this->alias[$type])) {
            foreach ($this->alias[$type] as $target) {
                $this->addTypePreCallFunction($target, $function);
            }
            return;
        }

        $this->tPreCallFunctions[$type][] = $function;
    }
395101
public function fold(callable $f)
    {
        $fold = function (Tree $tree) use (&$fold, $f) {
            return $f($tree->node, \array_map($fold, $tree->children));
        };
        return $fold($this);
    }
341089
public function find(callable $func)
    {
        $found = null;

        foreach ($this->elements as $key => $value) {
            if($func($value, $key)) {
                $found = $value;
                break;
            }
        }

        return $found;
    }
419153
public static function combine(/* $func1, $func2, ... */)
    {
        $functions = func_get_args();

        foreach ($functions as $function) {
            static::validate($function);
        }

        return function() use ($functions) {
            $result = array();
            $args = func_get_args();

            foreach ($functions as $function) {
                $result[] = call_user_func_array($function, $args);
            }

            return $result;
        };
    }
4477
public static function map(callable $function, $traversable)
    {
        $aggregation = [];

        foreach ($traversable as $key => $value) {
            $aggregation[$key] = $function($value, $key);
        }

        return $aggregation;
    }
396273
public function map(callable $func)
    {
        // That's the standard case for any next stages
        if (\is_iterable($this->pipeline)) {
            $this->pipeline = self::apply($this->pipeline, $func);

            return $this;
        }

        // Let's check what we got for a start
        $this->pipeline = $func();

        // Generator is a generator, moving along
        if ($this->pipeline instanceof \Generator) {
            return $this;
        }

        // Not a generator means we were given a simple value to be treated as an array
        // We do not cast to an array here because casting a null to an array results in
        // an empty array; that's surprising and not how map() works for other values
        $this->pipeline = [
            $this->pipeline,
        ];

        return $this;
    }
1349373
def compose(f: Callable[[Any], Monad], g: Callable[[Any], Monad]) -> Callable[[Any], Monad]:
    
    """
    return lambda x: g(x).bind(f)
574217
public function compose() {
    $functions = self::_wrapArgs(func_get_args(), 1);
    
    return self::_wrap(function() use ($functions) {
      $args = func_get_args();
      foreach($functions as $function) {
        $args[0] = call_user_func_array($function, $args);
      }
      return $args[0];
    });
  }
1037776
public function setApplyFilterFunction(callable $function)
    {
        $validator = $this->getCallableValidatorApplyFilters();
        $validator->setCallableFunction($function);

        if ($validator->isValid() === false) {
            throw $validator->getException();
        }

        $this->applyFilterFunction = $function;

        return $this;
    }
272510
public function map(callable $f) : Result
    {
        $result = new self(array_map($f, $this->errors));
        $result->fatal = $this->fatal;

        return $result;
    }
173722
public function filter(callable $func)
    {
        if (!$this->pipeline) {
            // No-op: either an empty array or null.
            return $this;
        }

        // We got an array, that's what we need. Moving along.
        if (\is_array($this->pipeline)) {
            $this->pipeline = \array_filter($this->pipeline, $func);

            return $this;
        }

        // CallbackFilterIterator needs a plain Iterator
        if (!$this->pipeline instanceof \Iterator) {
            $this->pipeline = new \IteratorIterator($this->pipeline);
        }

        $this->pipeline = new \CallbackFilterIterator($this->pipeline, $func);

        return $this;
    }
57663
protected function _getPortableFunctionsList($functions)
    {
        $list = [];
        foreach ($functions as $value) {
            $value = $this->_getPortableFunctionDefinition($value);

            if (! $value) {
                continue;
            }

            $list[] = $value;
        }

        return $list;
    }
739008
public function addFunction($function) {
		$arguments = func_get_args();
		// Remove the first argument
		array_shift($arguments);
	
		$content = new HtmlFromFunction();
		$content->functionPointer = $function;
		$content->parameters = $arguments;
		$this->children[] = $content;
		return $this;
	}