Skip to content

Instantly share code, notes, and snippets.

@FernandoCutire
Created January 13, 2022 02:13
Show Gist options
  • Save FernandoCutire/792cef7987f2fd5f4968e210512e1bbf to your computer and use it in GitHub Desktop.
Save FernandoCutire/792cef7987f2fd5f4968e210512e1bbf to your computer and use it in GitHub Desktop.
def unfold(fn, seed):
def fn_generator(val):
while True:
val = fn(val[1])
if val == False: break
yield val[0]
return [i for i in fn_generator([None, seed])]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment