def test_drop(): assert list(drop(3, 'ABCDE')) == list('DE') assert list(drop(1, (3, 2, 1))) == list((2, 1))
def drop_gaps_because_insertion_offsets(A, off_pos): '''remove those N values that are the minimum of those greater than the offset position, where N is offset''' off, pos = off_pos before, after = partition(lambda x: x >= pos, A) return itertools.chain.from_iterable([before, drop(off, imap(lambda x: x+off, after))])