Skip to content

Instantly share code, notes, and snippets.

@zerone0x
Created January 21, 2022 14:28
Show Gist options
  • Save zerone0x/77abcf4a6b8795cca1bfd8e2f740fbdc to your computer and use it in GitHub Desktop.
Save zerone0x/77abcf4a6b8795cca1bfd8e2f740fbdc to your computer and use it in GitHub Desktop.
generator of py
def merge(a, b):
first_a, first_b = next(a), next(b)
while True:
if first_a == first_b:
yield first_a
first_a, first_b = next(a), next(b)
elif first_a < first_b:
yield first_a
first_a = next(a)
else:
yield first_b
first_b = next(b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment