Last active
August 29, 2015 14:02
-
-
Save spitz-dan-l/f2bddaaae96daf80189b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_spans_gen(s, spans): | |
checker = make_range_checker(spans); next(checker) | |
return ''.join(c for (i, c) in enumerate(s) if not checker.send(i)) | |
def make_range_checker(spans): | |
idx = yield | |
for (i, j) in spans: | |
while idx < j: | |
idx = (yield i <= idx < j) | |
while True: | |
yield False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment