def foldl(function, list, initial):
    """
    Given a function, a list, and initial accumulator,
    fold (reduce) each item into the accumulator from the left using function(accumulator, item)
    """
    for item in list:
        initial = function(initial, item)
    return initial