Created
July 4, 2014 15:01
-
-
Save hoelzro/9d9d706015993745805c to your computer and use it in GitHub Desktop.
lazy-gather
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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