More on Generation Size
Learn scaling and modifications of generation size.
We'll cover the following
If we want to apply some modifications to the generation size, we’re looking for the StreamData.scale/2
function. It takes a generator and a function that takes a size and returns a new size, and then it returns a new generator. The new generator uses the generation size returned by the passed function. (That was a mouthful.) Essentially, it modifies the generation size of a generator in a dynamic way, based on the original generation size.
Scaling in generation size
Scaling is especially useful in a couple of scenarios. The first one is when we want to increase or decrease the speed at which the generation size progresses. For example, it might be a good idea to reduce the growth of the generation size for a complex and deeply nested generator. To do that, we can scale the generation size with mathematic functions like square roots:
Executable
Get hands-on with 1200+ tech skills courses.