How laziness works
Internally, lists have two parts:
- A reified part containing the items already generated
- A generator part specifying how to generate remaining items
Range example:
> my $r = 100..200; say $r.WHAT; Range(); > say $r.reify(5).perl; (100, 101, 102, 103, 104, 105..200)
The .reify method requests generation of $n elements
continued...