Talk:Closure (computer programming): Difference between revisions

Content deleted Content added
closures in perl
No edit summary
Line 8:
sub counter {
my $x = shift;
return sub { print "$x\n"; $x--; };
"; $x--; };
}
 
Line 15 ⟶ 14:
$g = counter(7);
 
&$h(); # gives 45
&$h(); # gives 3
&$g(); # gives 7