Skip to content

Instantly share code, notes, and snippets.

@BenMaydan
Created August 6, 2019 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenMaydan/a502084686779b79ae1a5fd0163ddc84 to your computer and use it in GitHub Desktop.
Save BenMaydan/a502084686779b79ae1a5fd0163ddc84 to your computer and use it in GitHub Desktop.
A generator function for iterating over a list of values in python. Computes the values on the fly
def generator(array):
"""
Takes a list of values and generates the current value on the fly
:param array: A list of values
:return: The current value
"""
idx = 0
while idx < len(array):
yield array[idx]
idx += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment