def reductions(seq, func, start=0):
    """
    return an iterator of the partial values of the reduction.
    the last value is always equal to reduce(func, seq, start)
    """
    out = start
    it = iter(seq)
    while True:
        try:
            yield out
            out = func(out, next(it))
        except StopIteration:
            raise StopIteration
