Perl 6 More laziness and lists #24

Generic pattern for SomeIter.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 if needed);
        }
        $!reified;
    }
}
Copyright © 2012
http://www.pmichaud.com/2012/pres/