Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created July 4, 2014 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoelzro/9d9d706015993745805c to your computer and use it in GitHub Desktop.
Save hoelzro/9d9d706015993745805c to your computer and use it in GitHub Desktop.
lazy-gather
use v6;
my @input;
sub stream {
LEAVE {
say "it's over";
}
gather {
for @input {
take $_;
}
}
}
@input = 1 .. 10;
for stream() {
.say;
if $_ == 1 {
say 'grabbing an element from @input';
@input.shift;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment