Skip to content

Instantly share code, notes, and snippets.

@moritz
Created July 28, 2013 11:05
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 moritz/6098219 to your computer and use it in GitHub Desktop.
Save moritz/6098219 to your computer and use it in GitHub Desktop.
Emulated state variables + closure cloning
for 1, 2 -> $x {
my &rec = {
my $m = 0;
sub ($n) {
return unless $n;
$m++;
say "$x-$m";
rec $n - 1
}
}();
rec 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment