| 1 | package List::MoreUtils::PP; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 118 | ▶ | use 5.008_001; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 118 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 118 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 118 | our $VERSION = '0.427_001'; | |||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | List::MoreUtils::PP - Provide List::MoreUtils pure Perl implementation | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | BEGIN { $ENV{LIST_MOREUTILS_PP} = 1; } | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | use List::MoreUtils qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | sub any (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | return 1 if $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | sub all (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return 0 unless $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | sub none (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
none: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | return 0 if $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | sub notall (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notall: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | return 1 unless $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | sub one (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
one: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $f->() and $found++ and return 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&$f() and $found++
MC/DC0%0/2
&$f() and $found++
&$f()
$found++
Truth table0%0/3
A and B
A= &$f()B= $found++
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | sub any_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_u: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $f->() and return 1 foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | sub all_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_u: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | $f->() or return 0 foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | sub none_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
none_u: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | $f->() and return 0 foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | sub notall_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
notall_u: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $f->() or return 1 foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | sub one_u (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
one_u: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | return if !@_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $f->() and $found++ and return 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
&$f() and $found++
MC/DC0%0/2
&$f() and $found++
&$f()
$found++
Truth table0%0/3
A and B
A= &$f()B= $found++
| |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | sub reduce_u(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reduce_u: not called CC=2 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 118 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | *$caller_a = \(); | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | for (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | *$caller_b = \$_[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | *$caller_a = \($code->()); | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ${*$caller_a}; | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | sub reduce_0(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 141 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reduce_0: not called CC=2 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | 118 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | *$caller_a = \0; | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | for (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 155 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | *$caller_b = \$_[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | *$caller_a = \($code->()); | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ${*$caller_a}; | |||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | sub reduce_1(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reduce_1: not called CC=2 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 171 | 118 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 173 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | *$caller_a = \1; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | for (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 178 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | *$caller_b = \$_[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | *$caller_a = \($code->()); | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ${*$caller_a}; | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||
| 186 | sub true (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
true: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | $f->() and ++$count foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return $count; | |||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | sub false (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
false: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $f->() or ++$count foreach (@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | return $count; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | sub firstidx (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firstidx: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | foreach my $i (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 206 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | local *_ = \$_[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | return $i if $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | sub firstval (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firstval: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | return $_ if $test->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | sub firstres (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
firstres: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $testval = $test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | $testval and return $testval; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | sub onlyidx (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
onlyidx: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $found; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | foreach my $i (0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | local *_ = \$_[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | $f->() or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | defined $found and return -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $found = $i; | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | return defined $found ? $found : -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | sub onlyval (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
onlyval: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $result = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $test->() or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $result = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | $found++ and return undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | sub onlyres (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
onlyres: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my $result = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | foreach (@_) | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | my $rv = $test->() or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $result = $rv; | |||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $found++ and return undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | return $found ? $result : undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | sub lastidx (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my $f = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lastidx: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | foreach my $i (reverse 0 .. $#_) | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | local *_ = \$_[$i]; | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | return $i if $f->(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | sub lastval (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lastval: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $ix; | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | for ($ix = $#_; $ix >= 0; $ix--) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | local *_ = \$_[$ix]; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $testval = $test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # Simulate $_ as alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $_[$ix] = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | return $_ if $testval; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | sub lastres (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lastres: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my $ix; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | for ($ix = $#_; $ix >= 0; $ix--) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | local *_ = \$_[$ix]; | |||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $testval = $test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | # Simulate $_ as alias | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $_[$ix] = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | return $testval if $testval; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | sub insert_after (&$\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | my ($f, $val, $list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_after: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $c = &firstidx($f, @$list); | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | @$list = (@{$list}[0 .. $c], $val, @{$list}[$c + 1 .. $#$list],) and return 1 if $c != -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$c != -1 && ((@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])) && (return 1))
@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*]) and return 1
MC/DC0%0/2
$c != -1 && ((@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])) && (return 1))
$c != -1
@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])
Truth table0%0/3
A && B
A= $c != -1B= @$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | sub insert_after_string ($$\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | my ($string, $val, $list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert_after_string: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | my $c = firstidx { defined $_ and $string eq $_ } @$list; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | @$list = (@{$list}[0 .. $c], $val, @{$list}[$c + 1 .. $#$list],) and return 1 if $c != -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$c != -1 && ((@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])) && (return 1))
@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*]) and return 1
MC/DC0%0/2
$c != -1 && ((@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])) && (return 1))
$c != -1
@$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])
Truth table0%0/3
A && B
A= $c != -1B= @$list = (@{$list;}[0 .. $c], $val, @{$list;}[$c + 1 .. $list->$#*])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | sub apply (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | my $action = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | &$action foreach my @values = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | wantarray ? @values : $values[-1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | sub after (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | my $started; | |||||||||||||||||||||||||||||||||||||||||||||
| 346 | my $lag; | ||||||||||||||||||||||||||||||||||||||||||||||
| 347 | grep $started ||= do | ||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$started ||= do {
my $x = $lag;
$lag = &$test();
$x
}
MC/DC0%0/2
$started ||= do {
my $x = $lag;
$lag = &$test();
$x
}
$started
do {
my $x = $lag;
$lag = &$test();
$x
}
Truth table0%0/3
A ||= B
A= $startedB= do {
my $x = $lag;
$lag = &$test();
$x
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my $x = $lag; | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $lag = $test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $x; | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | }, @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||
| 355 | sub after_incl (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
after_incl: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | my $started; | |||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | grep $started ||= $test->(), @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$started ||= &$test()
MC/DC0%0/2
$started ||= &$test()
$started
&$test()
Truth table0%0/3
A ||= B
A= $startedB= &$test()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | sub before (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my $more = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | grep $more &&= !$test->(), @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$more &&= !&$test()
MC/DC0%0/2
$more &&= !&$test()
$more
!&$test()
Truth table0%0/3
A &&= not(B)
A= $moreB= !&$test()
| |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | sub before_incl (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before_incl: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | my $more = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $lag = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | grep $more &&= do | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$more &&= do {
my $x = $lag;
$lag = !&$test();
$x
}
MC/DC0%0/2
$more &&= do {
my $x = $lag;
$lag = !&$test();
$x
}
$more
do {
my $x = $lag;
$lag = !&$test();
$x
}
Truth table0%0/3
A &&= B
A= $moreB= do {
my $x = $lag;
$lag = !&$test();
$x
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $x = $lag; | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | $lag = !$test->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $x; | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | }, @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | sub indexes (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | my $test = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indexes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | grep { | ||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | local *_ = \$_[$_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $test->() | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | } 0 .. $#_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | sub pairwise (&\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | my $op = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pairwise: not called CC=4 SCAR=23.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # Symbols for caller's input arrays | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 118 | ▶ | use vars qw{ @A @B }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | local (*A, *B) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # Localise $a, $b | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | my ($caller_a, $caller_b) = do | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | { | |||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $pkg = caller(); | |||||||||||||||||||||||||||||||||||||||||||||
| 403 | 118 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | \*{$pkg . '::a'}, \*{$pkg . '::b'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | # Loop iteration limit | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | my $limit = $#A > $#B ? $#A : $#B; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # This map expression is also the return value | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | local (*$caller_a, *$caller_b); | |||||||||||||||||||||||||||||||||||||||||||||
| 412 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # Assign to $a, $b as refs to caller's array elements | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | (*$caller_a, *$caller_b) = \($#A < $_ ? undef : $A[$_], $#B < $_ ? undef : $B[$_]); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # Perform the transformation | ||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | $op->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | } 0 .. $limit; | ||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | sub each_array (\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | return each_arrayref(@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each_array: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | sub each_arrayref | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | my @list = @_; # The list of references to the arrays | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each_arrayref: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my $index = 0; # Which one the caller will get next | |||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my $max = 0; # Number of elements in longest array | |||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | # Get the length of the longest input array | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | foreach (@list) | |||||||||||||||||||||||||||||||||||||||||||||
| 434 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | unless (ref $_ eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | Carp::croak("each_arrayref: argument is not an array reference\n"); | |||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $max = @$_ if @$_ > $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # Return the iterator as a closure wrt the above variables. | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | my $method = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | unless ($method eq 'index') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | Carp::croak("each_array: unknown argument '$method' passed to iterator."); | |||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # Return current (last fetched) index | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | return undef if $index == 0 || $index > $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$index == 0 or $index > $max
MC/DC0%0/2
$index == 0 or $index > $max
$index == 0
$index > $max
Truth table0%0/3
A or B
A= $index == 0B= $index > $max
| |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | return $index - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # No more elements to return | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | return if $index >= $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $i = $index++; | |||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # Return ith elements | ||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return map $_->[$i], @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | sub natatime ($@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | my $n = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
natatime: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my @list = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 472 | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | return splice @list, 0, $n; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # "leaks" when lexically hidden in arrayify | ||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 118 | my $flatten; | |||||||||||||||||||||||||||||||||||||||||||||
| 479 | $flatten = sub { | ||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | map { (ref $_ and ("ARRAY" eq ref $_ or overload::Method($_, '@{}'))) ? ($flatten->(@{$_})) : ($_) } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
Condition0%0/6
ref $_ and "ARRAY" eq ref $_ || overload::Method($_, "\@{}")
"ARRAY" eq ref $_ or overload::Method($_, "\@{}")
MC/DC0%0/3
ref $_ and "ARRAY" eq ref $_ || overload::Method($_, "\@{}")
ref $_
"ARRAY" eq ref $_
overload::Method($_, "\@{}")
Truth table0%0/4
A and B or C
A= ref $_B= "ARRAY" eq ref $_C= overload::Method($_, "\@{}")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 118 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||
| 483 | sub arrayify | ||||||||||||||||||||||||||||||||||||||||||||||
| 484 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | map { $flatten->($_) } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
arrayify: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||
| 488 | sub mesh (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | my $max = -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mesh: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | $max < $#$_ && ($max = $#$_) foreach @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my $ix = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | map $_->[$ix], @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 495 | } 0 .. $max; | ||||||||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||
| 498 | sub zip6 (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | my $max = -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
zip6: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | $max < $#$_ && ($max = $#$_) foreach @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | map { | ||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $ix = $_; | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | [map $_->[$ix], @_]; | |||||||||||||||||||||||||||||||||||||||||||||
| 505 | } 0 .. $max; | ||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | sub listcmp (\@\@;\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | my %ret; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
listcmp: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | for (my $i = 0; $i < scalar @_; ++$i) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 512 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my %seen; | |||||||||||||||||||||||||||||||||||||||||||||
| 514 | my $k; | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | foreach my $w (grep { defined $_ and not $seen{$k = $_}++ } @{$_[$i]}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 516 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | $ret{$w} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ret{$w} ||= []
MC/DC0%0/1
$ret{$w} ||= []
$ret{$w}
Truth table0%0/2
A
A= $ret{$w}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | push @{$ret{$w}}, $i; | |||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | %ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||
| 524 | sub uniq (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 525 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uniq: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 528 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | sub singleton (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 533 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
singleton: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 536 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | grep { 1 == (defined $_ ? $seen{$k = $_} : $seen_undef) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | sub duplicates (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
duplicates: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 545 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | grep { 1 < (defined $_ ? $seen{$k = $_} : $seen_undef) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||
| 550 | sub frequency (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 551 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
frequency: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 554 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | my %h = map { defined $_ ? ($_ => $seen{$k = $_}) : () } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | wantarray or return (scalar keys %h) + ($seen_undef ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | undef $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | ▶ | (%h, $seen_undef ? (\$k => $seen_undef) : ()); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||
| 562 | sub occurrences (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 563 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
occurrences: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 566 | my $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | foreach my $l (map { $_ } grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 569 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | my $n = defined $l ? $seen{$l} : $seen_undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | defined $ret[$n] or $ret[$n] = []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | push @{$ret[$n]}, $l; | |||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||
| 577 | sub mode (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 578 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | my %seen = (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mode: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my ($max, $k, $seen_undef) = (1); | |||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | foreach (@_) { defined $_ ? ($max < ++$seen{$k = $_} and ++$max) : ($max < ++$seen_undef and ++$max) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$max < ++$seen{$k = $_} and ++$max
$max < ++$seen_undef and ++$max
MC/DC0%0/2
$max < ++$seen{$k = $_} and ++$max
$max < ++$seen{$k = $_}
++$max
MC/DC0%0/2
$max < ++$seen_undef and ++$max
$max < ++$seen_undef
++$max
Truth table0%0/3
A and B
A= $max < ++$seen{$k = $_}B= ++$max
Truth table0%0/3
A and B
A= $max < ++$seen_undefB= ++$max
| |||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | wantarray or return $max; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my @ret = ($max); | |||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | foreach my $l (grep { $seen{$_} == $max } keys %seen) | |||||||||||||||||||||||||||||||||||||||||||||
| 587 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | push @ret, $l; | |||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | $seen_undef and $seen_undef == $max and push @ret, undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$seen_undef and $seen_undef == $max
MC/DC0%0/2
$seen_undef and $seen_undef == $max
$seen_undef
$seen_undef == $max
Truth table0%0/3
A and B
A= $seen_undefB= $seen_undef == $max
| |||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | @ret; | |||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||
| 594 | sub samples ($@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 595 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | my $n = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
samples: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | if ($n > @_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 598 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | Carp::croak(sprintf("Cannot get %d samples from %d elements", $n, scalar @_)); | |||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | for (my $i = @_; @_ - $i > $n;) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 604 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $idx = @_ - $i; | |||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my $swp = $idx + int(rand(--$i)); | |||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | my $xchg = $_[$swp]; | |||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $_[$swp] = $_[$idx]; | |||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $_[$idx] = $xchg; | |||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | return splice @_, 0, $n; | |||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||
| 615 | sub minmax (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 616 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minmax: not called CC=14 SCAR=53.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my $min = my $max = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | for (my $i = 1; $i < @_; $i += 2) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 621 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | if ($_[$i - 1] <= $_[$i]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 623 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | $min = $_[$i - 1] if $min > $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | $max = $_[$i] if $max < $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 627 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 628 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | $min = $_[$i] if $min > $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | $max = $_[$i - 1] if $max < $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | if (@_ & 1) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 635 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | my $i = $#_; | |||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if ($_[$i - 1] <= $_[$i]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 638 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | $min = $_[$i - 1] if $min > $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | $max = $_[$i] if $max < $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 642 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 643 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | ▶ | $min = $_[$i] if $min > $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | $max = $_[$i - 1] if $max < $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 0 | return ($min, $max); | |||||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||
| 652 | sub minmaxstr (@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 653 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minmaxstr: not called CC=14 SCAR=53.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my $min = my $max = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | for (my $i = 1; $i < @_; $i += 2) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 658 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | if ($_[$i - 1] le $_[$i]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 660 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | $min = $_[$i - 1] if $min gt $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | $max = $_[$i] if $max lt $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 664 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 665 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | $min = $_[$i] if $min gt $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | $max = $_[$i - 1] if $max lt $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | if (@_ & 1) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 672 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $i = $#_; | |||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | if ($_[$i - 1] le $_[$i]) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 675 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | ▶ | $min = $_[$i - 1] if $min gt $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | $max = $_[$i] if $max lt $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 679 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 680 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | $min = $_[$i] if $min gt $_[$i]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | $max = $_[$i - 1] if $max lt $_[$i - 1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | return ($min, $max); | |||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||
| 689 | sub part (&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 690 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | my ($code, @list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | push @{$parts[$code->($_)]}, $_ foreach @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | return @parts; | |||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||
| 697 | sub bsearch(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 698 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsearch: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | my $rc; | |||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | my $j = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 704 | do | ||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | my $k = int(($i + $j) / 2); | |||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | $k >= @_ and return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | local *_ = \$_[$k]; | |||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | $rc = $code->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | $rc == 0 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 714 | and return wantarray ? $_ : 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 0 | ▶ | if ($rc < 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 717 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | $i = $k + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 720 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 721 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | $j = $k - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 724 | } until $i > $j; | ||||||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 727 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||
| 729 | sub bsearchidx(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 730 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bsearchidx: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | my $rc; | |||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $j = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 736 | do | ||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | my $k = int(($i + $j) / 2); | |||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | $k >= @_ and return -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | local *_ = \$_[$k]; | |||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | $rc = $code->(); | |||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | $rc == 0 and return $k; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | ▶ | if ($rc < 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 748 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | $i = $k + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 751 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 752 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | $j = $k - 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } until $i > $j; | ||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||
| 760 | sub lower_bound(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 761 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lower_bound: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | my $count = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | my $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | while ($count > 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 766 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my $step = $count >> 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my $it = $first + $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | local *_ = \$_[$it]; | |||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | if ($code->() < 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 771 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | $first = ++$it; | |||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | $count -= $step + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 775 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 776 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | $count = $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | $first; | |||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||
| 784 | sub upper_bound(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 785 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | my $code = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upper_bound: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | my $count = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | my $first = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | ▶ | while ($count > 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 790 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | my $step = $count >> 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | my $it = $first + $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | local *_ = \$_[$it]; | |||||||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | ▶ | if ($code->() <= 0) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 795 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | $first = ++$it; | |||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $count -= $step + 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 799 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 800 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | $count = $step; | |||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $first; | |||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||
| 808 | sub equal_range(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 809 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | ▶ | my $lb = &lower_bound(@_); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
equal_range: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | my $ub = &upper_bound(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ($lb, $ub); | |||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||
| 815 | sub binsert (&$\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 816 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | ▶ | my $lb = &lower_bound($_[0], @{$_[2]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binsert: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | splice @{$_[2]}, $lb, 0, $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | $lb; | |||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||
| 822 | sub bremove (&\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 823 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | ▶ | my $lb = &lower_bound($_[0], @{$_[1]}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bremove: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | splice @{$_[1]}, $lb, 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||
| 828 | sub qsort(&\@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 829 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | ▶ | require Carp; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
qsort: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | Carp::croak("It's insane to use a pure-perl qsort"); | |||||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||
| 834 | sub sort_by(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 835 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | my ($code, @list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_by: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | return map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | sort { $a->[1] cmp $b->[1] } | |||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | map { [$_, scalar($code->())] } @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||
| 842 | sub nsort_by(&@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 843 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | my ($code, @list) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nsort_by: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | return map { $_->[0] } | |||||||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | sort { $a->[1] <=> $b->[1] } | |||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | map { [$_, scalar($code->())] } @list; | |||||||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | sub _XScompiled { 0 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_XScompiled: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||
| 852 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||
| 854 | L<List::Util> | ||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||
| 856 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||
| 858 | Jens Rehsack E<lt>rehsack AT cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||
| 860 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||
| 862 | Tassilo von Parseval E<lt>tassilo.von.parseval@rwth-aachen.deE<gt> | ||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||
| 864 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | Some parts copyright 2011 Aaron Crane. | ||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||
| 868 | Copyright 2004 - 2010 by Tassilo von Parseval | ||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||
| 870 | Copyright 2013 - 2017 by Jens Rehsack | ||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||
| 872 | All code added with 0.417 or later is licensed under the Apache License, | ||||||||||||||||||||||||||||||||||||||||||||||
| 873 | Version 2.0 (the "License"); you may not use this file except in compliance | ||||||||||||||||||||||||||||||||||||||||||||||
| 874 | with the License. You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||
| 876 | http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||
| 878 | Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||||||||||||||||
| 879 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||||||||||||||||
| 880 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||||||||||||||||
| 881 | See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||||||||||||||||
| 882 | limitations under the License. | ||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||
| 884 | All code until 0.416 is licensed under the same terms as Perl itself, | ||||||||||||||||||||||||||||||||||||||||||||||
| 885 | either Perl version 5.8.4 or, at your option, any later version of | ||||||||||||||||||||||||||||||||||||||||||||||
| 886 | Perl 5 you may have available. | ||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||
| 888 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 118 | 1; | |||||||||||||||||||||||||||||||||||||||||||||