def reduce(function, iterable, initial):
    """
    Functional reduce function.

    Take an iterable and apply the specified function to each element.
    The result is fed into the next function call.
    """
    accumulator = initial
    for (index, item) in enumerate(iterable):
        accumulator = function(accumulator, item, index, iterable)
    return accumulator