June 2017
Beginner
352 pages
8h 39m
English
Generators are lazy, meaning that computation only happens just-in-time when the next result is requested. This interesting and useful property of generators means they can be used to model infinite sequences. Since values are only produced as requested by the caller, and since no data structure needs to be built to contain the elements of the sequence, generators can safely be used to produce never-ending (or just very large) sequences like:
Read now
Unlock full access