- or download this
sub upto {
my ( $m, $n ) = @_;
...
return $m++;
};
}
- or download this
sub upto {
my ( $m, $n ) = @_;
return sub { $m <= $n ? $m++ : () };
}
- or download this
my $iter = upto( -2, 2 );
while ( my ( $ele ) = $iter->() ) {
say $ele;
}
- or download this
-2
-1
0
1
2
- or download this
sub list {
my @a = @_;
...
while ( my ( $ele ) = $iter->() ) ) {
say $ele // "[undef]";
}
- or download this
1
0
[undef]
a