Generic pattern for Iterator.reify
class SomeIter is Iterator { has $!reified; method reify($n = 1) { unless defined($!reified) { # ...generation of $n elements... $!reified := (parcel of generated elements and next iterator); } $!reified; } }
Perl 6 | Perl 6 Lists, Arrays, and Hashes vivified | #56 |
class SomeIter is Iterator { has $!reified; method reify($n = 1) { unless defined($!reified) { # ...generation of $n elements... $!reified := (parcel of generated elements and next iterator); } $!reified; } }
Copyright © 2011 http://www.pmichaud.com/2011/pres/ |