| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SHARYANTO::List::Util; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24099
|
use 5.010; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
35
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
35
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
571
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
|
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
10
|
|
|
|
|
|
|
uniq_adj |
|
11
|
|
|
|
|
|
|
uniq_adj_ci |
|
12
|
|
|
|
|
|
|
uniq_ci |
|
13
|
|
|
|
|
|
|
find_missing_nums_in_seq |
|
14
|
|
|
|
|
|
|
find_missing_strs_in_seq |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.75'; # VERSION |
|
18
|
|
|
|
|
|
|
our $DATE = '2014-06-26'; # DATE |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub uniq_adj { |
|
21
|
2
|
|
|
2
|
1
|
3672
|
my @res; |
|
22
|
|
|
|
|
|
|
|
|
23
|
2
|
50
|
|
|
|
11
|
return () unless @_; |
|
24
|
2
|
|
|
|
|
5
|
my $last = shift; |
|
25
|
2
|
|
|
|
|
7
|
push @res, $last; |
|
26
|
2
|
|
|
|
|
6
|
for (@_) { |
|
27
|
12
|
0
|
33
|
|
|
25
|
next if !defined($_) && !defined($last); |
|
28
|
|
|
|
|
|
|
# XXX $_ becomes stringified |
|
29
|
12
|
100
|
33
|
|
|
85
|
next if defined($_) && defined($last) && $_ eq $last; |
|
|
|
|
66
|
|
|
|
|
|
30
|
10
|
|
|
|
|
17
|
push @res, $_; |
|
31
|
10
|
|
|
|
|
17
|
$last = $_; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
2
|
|
|
|
|
24
|
@res; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub uniq_adj_ci { |
|
37
|
1
|
|
|
1
|
1
|
3
|
my @res; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
50
|
|
|
|
5
|
return () unless @_; |
|
40
|
1
|
|
|
|
|
49
|
my $last = shift; |
|
41
|
1
|
|
|
|
|
4
|
push @res, $last; |
|
42
|
1
|
|
|
|
|
4
|
for (@_) { |
|
43
|
6
|
0
|
33
|
|
|
13
|
next if !defined($_) && !defined($last); |
|
44
|
|
|
|
|
|
|
# XXX $_ becomes stringified |
|
45
|
6
|
100
|
33
|
|
|
51
|
next if defined($_) && defined($last) && lc($_) eq lc($last); |
|
|
|
|
66
|
|
|
|
|
|
46
|
4
|
|
|
|
|
8
|
push @res, $_; |
|
47
|
4
|
|
|
|
|
7
|
$last = $_; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
1
|
|
|
|
|
9
|
@res; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub uniq_ci { |
|
53
|
1
|
|
|
1
|
1
|
2121
|
my @res; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my %mem; |
|
56
|
1
|
|
|
|
|
3
|
for (@_) { |
|
57
|
7
|
100
|
|
|
|
28
|
push @res, $_ unless $mem{lc $_}++; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
1
|
|
|
|
|
9
|
@res; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub find_missing_nums_in_seq { |
|
63
|
1
|
|
|
1
|
1
|
1993
|
require List::Util; |
|
64
|
|
|
|
|
|
|
|
|
65
|
1
|
|
|
|
|
3
|
my @res; |
|
66
|
1
|
|
|
|
|
14
|
my $min = List::Util::min(@_); |
|
67
|
1
|
|
|
|
|
5
|
my $max = List::Util::max(@_); |
|
68
|
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
3
|
my %h = map { $_=>1 } @_; |
|
|
7
|
|
|
|
|
18
|
|
|
70
|
1
|
|
|
|
|
4
|
for ($min..$max) { |
|
71
|
8
|
100
|
|
|
|
23
|
push @res, $_ unless $h{$_}; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
1
|
50
|
|
|
|
11
|
wantarray ? @res : \@res; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub find_missing_strs_in_seq { |
|
77
|
1
|
|
|
1
|
1
|
2160
|
require List::Util; |
|
78
|
|
|
|
|
|
|
|
|
79
|
1
|
|
|
|
|
3
|
my @res; |
|
80
|
1
|
|
|
|
|
6
|
my $min = List::Util::minstr(@_); |
|
81
|
1
|
|
|
|
|
3
|
my $max = List::Util::maxstr(@_); |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
4
|
my %h = map { $_=>1 } @_; |
|
|
3
|
|
|
|
|
10
|
|
|
84
|
1
|
|
|
|
|
6
|
for ($min..$max) { |
|
85
|
5
|
100
|
|
|
|
20
|
push @res, $_ unless $h{$_}; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
1
|
50
|
|
|
|
13
|
wantarray ? @res : \@res; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
# ABSTRACT: List utilities |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |