def __next__(self): try: self.rotate_current() except: try: self.next_chain() except: self.reset() next(self) raise StopIteration return pfi(self)
def next_chain(self): self.clear() try: chain = pfi(next(self.chains)) for link in chain: if type(link) == Scalar: self.append(str(link)) else: sum = generator(link) self.append(sum) next(sum) else: pass except BaseException as e: raise StopIteration
def getiter(self): return pfi(self, Sum)
def __init__(self, iterable): self.chains = pfi(iterable if type(iterable) == Sum else Sum([iterable])) self.baseState = self.chains.getState() self = []
def getiter(self): return pfi(self, Chain)