Allow accessing / retrieving the current item of `itertools.count`

Without my zip trick:

def iter_counter(iterable):
    counter = itl.count(1)
    return (
        itl.compress(iterable, counter),
        map(opr.sub, counter, itl.count(1)).__next__
    )
1 Like