async def counter(delay, to): # from transducer.coop import transduce # from transducer.reducers import effecting # await transduce( # transducer=compose( # enumerating(), # windowing(3) # ), # reducer=effecting(print), # aiterable=ticker(delay, to) # ) from transducer.lazy_coop import transduce async for item in transduce(transducer=compose(enumerating(), windowing(3)), aiterable=ticker(delay, to)): print(item)
def test_enumerating_with_start(self): result = transduce(transducer=enumerating(start=3), reducer=appending(), iterable=[2, 4, 6, 8, 10]) self.assertListEqual(result, [(3, 2), (4, 4), (5, 6), (6, 8), (7, 10)])
def test_enumerating(self): result = transduce(transducer=enumerating(), reducer=appending(), iterable=[2, 4, 6, 8, 10]) self.assertListEqual(result, [(0, 2), (1, 4), (2, 6), (3, 8), (4, 10)])