Skip to content

Instantly share code, notes, and snippets.

Created September 9, 2011 22:02
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 anonymous/1207447 to your computer and use it in GitHub Desktop.
Save anonymous/1207447 to your computer and use it in GitHub Desktop.
pmichaud@kiwi:~/p6/nom$ cat y
sub foo($x) {
my $tail = [];
my sub generate() {
nqp::say($tail.DUMP);
1;
}
GATHER({
take $x;
push $tail, $x;
generate();
take $x * 2;
}).list;
}
say foo(1);
say '-----';
say foo(1), foo(3);
pmichaud@kiwi:~/p6/nom$ ./perl6 y
Array<200970432>(:items(RPA<200232048>(▶1)), :nextiter(▶Mu))
1 2
-----
Array<198032336>(:items(▶Mu), :nextiter(ListIter<198032296>(:reified(▶Mu), :rest(RPA<198032376>(Parcel<198032576>(:storage(RPA<198032656>())))), :list(Array<198032336>))))
1 2Array<198032336>(:items(RPA<196399632>(▶3)), :nextiter(▶Mu))
3 6
pmichaud@kiwi:~/p6/nom$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment