Blocks the first *block* items from *values*, repeating the block after
    every *repeat_after* items, if *repeat_after* is non-zero. For example, to
    discard the first 50 values read from an ADC::

        from gpiozero import MCP3008
        from gpiozero.tools import pre_periodic_filtered

        adc = MCP3008(channel=0)

        for value in pre_periodic_filtered(adc, 50, 0):
            print(value)

    Or to only display every even item read from an ADC::

        from gpiozero import MCP3008
        from gpiozero.tools import pre_periodic_filtered

        adc = MCP3008(channel=0)

        for value in pre_periodic_filtered(adc, 1, 1):
            print(value)

def pre_periodic_filtered(values, block, repeat_after):
    """
    Blocks the first *block* items from *values*, repeating the block after
    every *repeat_after* items, if *repeat_after* is non-zero. For example, to
    discard the first 50 values read from an ADC::

        from gpiozero import MCP3008
        from gpiozero.tools import pre_periodic_filtered

        adc = MCP3008(channel=0)

        for value in pre_periodic_filtered(adc, 50, 0):
            print(value)

    Or to only display every even item read from an ADC::

        from gpiozero import MCP3008
        from gpiozero.tools import pre_periodic_filtered

        adc = MCP3008(channel=0)

        for value in pre_periodic_filtered(adc, 1, 1):
            print(value)
    """
    values = _normalize(values)
    if block < 1:
        raise ValueError("block must be 1 or larger")
    if repeat_after < 0:
        raise ValueError("repeat_after must be 0 or larger")
    it = iter(values)
    try:
        if repeat_after == 0:
            for _ in range(block):
                next(it)
            while True:
                yield next(it)
        else:
            while True:
                for _ in range(block):
                    next(it)
                for _ in range(repeat_after):
                    yield next(it)
    except StopIteration:
        pass