Skip to content

Commit

Permalink
Allow passing before_and_after remainders into before_and_after again
Browse files Browse the repository at this point in the history
  • Loading branch information
gleb-akhmerov committed Oct 14, 2022
1 parent d63ed69 commit 99a9faa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions more_itertools/recipes.py
Expand Up @@ -744,11 +744,12 @@ def true_iterator():
transition.append(elem)
return

def remainder_iterator():
yield from transition
yield from it
# Note: this is different from itertools recipes to allow nesting
# before_and_after remainders into before_and_after again. See tests
# for an example.
remainder_iterator = chain(transition, it)

return true_iterator(), remainder_iterator()
return true_iterator(), remainder_iterator


def triplewise(iterable):
Expand Down

0 comments on commit 99a9faa

Please sign in to comment.