Generators are a powerful tool in many programming languages. They are similar to functions in that they enable the encapsulation and reuse of computations. Yet, unlike functions, they can "return" multiple results and "accept" new inputs before they complete.

While generators are more common in languages like Python, they are a bit of an obscure...