An example of a Python generator returning an iterator for the Fibonacci numbers using Python's yield statement follows: def fibonacci(limit): a, b = 0, 1 for _ in range(limit): yield a a, b = b, a+b for number in fibonacci(100): # The generator constructs an iterator print(number) Some object-oriented languages such as C#, C++ (later versions), Delphi (later versions), Go, Java (later versions), Lua, Perl, Python, Ruby provide an intrinsic way of iterating through the elements of a container object without the introduction of an explicit iterator object.
De nada dejame adivinarWikiMatrix WikiMatrix