File Coverage

blib/lib/List/MapList.pm
Criterion Covered Total %
statement 20 20 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 31 31 100.0


line stmt bran cond sub pod time code
1 4     4   3292 use strict;
  4         9  
  4         160  
2 4     4   22 use warnings;
  4         11  
  4         273  
3             package List::MapList;
4             {
5             $List::MapList::VERSION = '1.123';
6             }
7             # ABSTRACT: map lists through a list of subs, not just one
8              
9 4     4   22 use Exporter 5.57 'import';
  4         145  
  4         885  
10             our @EXPORT = qw(mapcycle maplist); ## no critic
11              
12              
13             sub maplist {
14 2     2 1 892 my ($subs, $current) = (shift, 0);
15 2 100   17   6 my $code = sub { $subs->[$current++] || sub { () }; };
  17         68  
  9         27  
16 2         5 map { $code->()->() } @_;
  17         41  
17             }
18              
19              
20             sub mapcycle {
21 6     6 1 2471 my ($subs, $current) = (shift, 0);
22 6     77   16 my $code = sub { $subs->[$current++ % @$subs]; };
  77         138  
23 6         12 map { $code->()->() } @_;
  77         214  
24             }
25              
26             1;
27              
28             __END__