NAME
        reduce - chain an array through a function

SYNOPSIS
        mixed reduce(function func, mixed *array, void|mixed start)

DESCRIPTION
        Apply the function 'func' in pairs to an array, chaining the result of
        the first call as start value of the second call. The function 'func'
        should accept (at least) two arguments. If a start value is omitted,
        the first element of the array is used as start value. So only use the
        start value if you really have to. It is faster to omit it.

ARGUMENTS
        function func - the function to call for each pair. It must accept at
                        least two arguments of the type used in the array.
        mixed *array  - the array to chain through the function 'func'.
        mixed start   - OPTIONAL start value of the chain. If omitted, it uses
                        the first value of the array. Use only when necessary.

RETURNS
        Returns the value the function 'func' returns after its final round.

EXAMPLE
        To calculate the sum of an array, do:

            result = reduce( &operator(+)(,) , ({ 4, 5, 6 }) );

        This will execute:

            result = 4 + 5 = 9;
            result = 9 + 6 = 15;

        Note that if a start value 0 was used, it would have calculated the
        unnecessary result = 0 + 4 = 4 first.

NOTA BENE
        The efuns min and max have a built-in feature for getting the min/max
        of an array.

SEE ALSO
        functions, min, max
