Data-Enumerable-Lazy
view release on metacpan or search on metacpan
[enumerable.has_next] -> [_buffer.has_next] -> yes -> return true
-> no -> result = [enumerable.on_has_next] -> return result
[enumerable.next] -> [_buffer.has_next] -> yes -> return [_buffer.next]
-> no -> result = [enumerable.next] -> [enumerable.set_buffer(result)] -> return result
EXAMPLES
A basic range
This example implements a range generator from $from until $to. In order
to generate this range we define 2 callbacks: `on_has_next()' and
`on_next()'. The first one is used as point of truth whether the
sequence has any more non-iterated elements, and the 2nd one is here to
return the next element in the sequence and the one that changes the
state of the internal sequence iterator.
sub basic_range {
my ($from, $to) = @_;
$from <= $to or die '$from should be less or equal $to';
my $current = $from;
Data::Enumerable::Lazy->new({
lib/Data/Enumerable/Lazy.pm view on Meta::CPAN
-> no -> result = [enumerable.on_has_next] -> return result
[enumerable.next] -> [_buffer.has_next] -> yes -> return [_buffer.next]
-> no -> result = [enumerable.next] -> [enumerable.set_buffer(result)] -> return result
=head1 EXAMPLES
=head2 A basic range
This example implements a range generator from $from until $to. In order to
generate this range we define 2 callbacks: C<on_has_next()> and C<on_next()>.
The first one is used as point of truth whether the sequence has any more
non-iterated elements, and the 2nd one is here to return the next element in
the sequence and the one that changes the state of the internal sequence
iterator.
sub basic_range {
my ($from, $to) = @_;
$from <= $to or die '$from should be less or equal $to';
my $current = $from;
Data::Enumerable::Lazy->new({
( run in 0.738 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )