Created
August 6, 2019 06:25
-
-
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
This file contains 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 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