Data-Enumerable-Lazy
view release on metacpan or search on metacpan
satisfy the conditional callback. The callback takes only 1 argument: an
element. It should return true if the element should be taken. Once it
returned false, the stream is over.
continue($ext = %{ on_next => sub {}, ... })
Creates a new enumerable by extending the existing one. on_next is the
only manfatory argument. on_has_next might be overriden if some custom
logic comes into play.
is_finite is inherited from the parent enumerable by default. All
additional attributes would be transparently passed to the constuctor.
count()
Counts the number of the elements in the stream. This method iterates
through the stream so it makes it exhausted by the end of the
computatuion.
yield($result)
This method is supposed to be called from `on_next' callback only. This
is the only valid result for an Enumerable to return the next step
result. Effectively, it ensures the returned result conforms to the
lib/Data/Enumerable/Lazy.pm view on Meta::CPAN
});
}
=head2 continue($ext = %{ on_next => sub {}, ... })
Creates a new enumerable by extending the existing one. on_next is
the only manfatory argument. on_has_next might be overriden if some
custom logic comes into play.
is_finite is inherited from the parent enumerable by default. All additional
attributes would be transparently passed to the constuctor.
=cut
sub continue {
my ($this, $ext) = @_;
my %ext = %$ext;
my $on_next = delete $ext{on_next}
or croak '`on_next` should be defined on stream continuation';
ref($on_next) eq 'CODE'
or croak '`on_next` should be a function';
( run in 0.586 second using v1.01-cache-2.11-cpan-0a6323c29d9 )