def cumulative_sum(v, cumulative):
    """ This function is used to output a stream
    where the n-th value on the output stream is
    the cumulative sum of the first n values of the
    input stream.
    
    The state of the input stream is cumulative.
    When used to create a stream, cumulative is
    the sum of all the values in the input stream
    received so far.
    v is the next value received in the input stream.
    
    """
    cumulative += v
    return (cumulative, cumulative)