import functools


def reduce(iterable, iteratee, init=None):
    """
    Also known as inject, foldl or fold-left, reduce boils down a list of values 
    into a single value. init is the initial state of the reduction, and each 
    successive step of it should be returned by iteratee. The iteratee is passed 
    three arguments: the current_reduced_state, then the value and index (or key) of the iteration.

    If no init is passed to the initial invocation of reduce, the iteratee is not invoked on the first element of the list. The first element is instead passed as the memo in the invocation of the iteratee on the next element in the list. 

    params: iterable, iteratee, init
        iterable -> a list, tuple, iterator, generator, dictionary
        iteratee -> a function or a lambda
        init -> Inital value of the reduced state

    Examples:
    >>> total = _.reduce([1, 2, 3], lambda memo, val: memo + val, 0);
    # >>> twisted_total = _.reduce([1, 2, 3], lambda memo, val, index: memo + num*index, 0);
    """
    return functools.reduce(iteratee, iterable, init)