What Is an Iterator Protocol?
An iterator protocol is the agreed interface that lets code step through a collection one element at a time without knowing its internal structure. A type that implements it provides a way to produce successive elements and to signal when there are no more. Language loop constructs are usually built on top of this protocol.
Why it matters
A shared iteration interface lets the same loops and algorithms work over lists, trees, streams, and generators alike. It decouples how data is stored from how it is traversed.
Related guides
What Is a Generator?A generator is a function that can pause and resume, producing a sequence of values one at a time on demand r…
What Is Lazy Evaluation?Lazy evaluation delays computing an expression until its value is actually needed, and may skip it entirely i…
What Is a Higher-Order Function?A higher-order function takes other functions as arguments or returns a function as its result, treating beha…