closure_factory.pl

Perlマスター

Explorer

C40
C++40
C#40
Dart40
Go40
Java40
JavaScript40
Kotlin40
Objective-C40
Perl
初級10
中級10
上級10
エキスパート5
マスター5
moose_class.pl
tie_hash.pl
closure_factory.pl
overload_ops.pl
autoload_method.pl
PHP40
Python40
R40
Ruby40
Rust40
Shell40
Swift40
TypeScript40
closure_factory.pl
Click to focus
1
2
3
4
5
6
7
8
9
10
11
12
sub make_counter {
   my $start = shift // 0;
   my $step = shift // 1;
   return sub {
       my $current = $start;
       $start += $step;
       return $current;
   };
}
my $c1 = make_counter(10, 2);
my $c2 = make_counter(100, 10);
print $c1->(), $c2->();
0WPM0%0:000/258(0%)|Ln 1, Col 1
UTF-8Perl

関連する練習問題