>>> import itertools >>> from sumesp import sumes_parcials >>> it1 = iter(range(100)) >>> it2 = iter([2, 5, 1, 2, 6]) >>> itsum = sumes_parcials(it1, it2) >>> list(itsum) # doctesttag: +TAG=1_sumesp [1, 20, 7, 17, 75] >>> l1 = [1,-6,77,8,99,19,-22,67,-12,55,89,9,0,11,-2] >>> l2 = [3,1,4,7] >>> for x in sumes_parcials(iter(l1), iter(l2)): # doctesttag: +TAG=1_sumesp ... print(x, end=',') 72,8,163,150, >>> for x in sumes_parcials(iter(l1), iter([1,2]*5)): # doctesttag: +TAG=1_sumesp ... print(x, end=',') 1,71,8,118,-22,55,55,98,0,9, >>> for x in sumes_parcials(itertools.count(), iter([1000]*10)): # doctesttag: +TAG=1_sumesp ... print(x, end=',') 499500,1499500,2499500,3499500,4499500,5499500,6499500,7499500,8499500,9499500, >>> list(sumes_parcials(iter([3]*10), iter([2]*5))) # doctesttag: +TAG=1_sumesp [6, 6, 6, 6, 6] >>> list(sumes_parcials(iter([3,4]*6), iter([3]*4))) # doctesttag: +TAG=1_sumesp [10, 11, 10, 11] >>> it = sumes_parcials(iter([10]*10000), iter([10000])) >>> next(it) # doctesttag: +TAG=1_sumesp 100000 >>> next(it,'final') # doctesttag: +TAG=1_sumesp 'final' >>> it = sumes_parcials(itertools.count(),itertools.count(1)) >>> for i in range(25): # doctesttag: +TAG=1_sumesp ... print(next(it), end=',') 0,3,12,30,60,105,168,252,360,495,660,858,1092,1365,1680,2040,2448,2907,3420,3990,4620,5313,6072,6900,7800, >>> from anterior import modifica >>> itr = modifica(iter([3, 5, 2, 8]), [2, 4]) >>> list(itr) # doctesttag: +TAG=2_modifica [12, 30] >>> itr2 = modifica(iter([3, 5, 2, 8]), [1, 5]) >>> list(itr2) # doctesttag: +TAG=2_modifica [12, 6, 72] >>> itr2 = modifica(iter(range(20, 1, -2)), [5]) >>> list(itr2) # doctesttag: +TAG=2_modifica [420, 342, 272, 210, 156, 110, 72, 42, 20, 6] >>> itr2 = modifica(iter(range(30)), [0, 3, 4, 7]) >>> list(itr2) # doctesttag: +TAG=2_modifica [2, 12, 20, 30, 42, 56, 90, 132, 182, 210, 240, 272, 306, 380, 462, 552, 600, 650, 702, 756, 870] >>> itr2 = modifica(iter(range(50)), [0, 1, 2, 3, 4, 5, 6, 7, 8]) >>> list(itr2) # doctesttag: +TAG=2_modifica [12, 56, 182, 306, 552, 756, 1122, 1406, 1892, 2256] >>> itr2 = modifica(iter(range(5000)), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> list(itr2) # doctesttag: +TAG=2_modifica [] >>> itr2 = modifica(iter(range(10)), [0,1,4,5,6,9]) >>> next(itr2,'final') # doctesttag: +TAG=2_modifica 'final' >>> itr2 = modifica(iter(range(50)), []) >>> list(itr2) == [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110, 132, 156, 182, 210, 240, 272, 306, 342, 380, 420, 462, 506, 552, 600, 650, 702, 756, 812, 870, 930, 992, 1056, 1122, 1190, 1260, 1332, 1406, 1482, 1560, 1640, 1722, 1806, 1892, 1980, 2070, 2162, 2256, 2352, 2450] # doctesttag: +TAG=2_modifica True >>> itr2 = modifica(itertools.count(), []) >>> for i in range(25): # doctesttag: +TAG=2_modifica ... print (next(itr2),end=',') 0,2,6,12,20,30,42,56,72,90,110,132,156,182,210,240,272,306,342,380,420,462,506,552,600,