| 1 | package Set::Product::PP; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Scalar::Util qw(reftype); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 3 | our @EXPORT_OK = qw(product); | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | sub product (&@) { | ||||||||||||||||||||||||||||
| 13 | 6 | ▶ | my ($sub, @in) = @_; | ||||||||||||||||||||||||||
|
Subroutine
product: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 6 | ▶ | croak 'Not a subroutine reference' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
builtin::reftype($sub) || ''
MC/DC0%0/1
builtin::reftype($sub) || ''
builtin::reftype($sub)
Truth table50%1/2
A
A= builtin::reftype($sub)
| |||||||||||||||||||||||||||||
| 16 | unless 'CODE' eq (reftype($sub) || ''); | ||||||||||||||||||||||||||||
| 17 | croak 'Not an array reference' | ||||||||||||||||||||||||||||
| 18 | 6 | ▶ | if grep { 'ARRAY' ne (reftype($_) || '') } @in; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
builtin::reftype($_) || ''
MC/DC100%1/1
builtin::reftype($_) || ''
builtin::reftype($_)
Truth table100%2/2
A
A= builtin::reftype($_)
| |||||||||||||||||||||||||||||
| 19 | 5 | ▶ | return if ! @in or grep { ! @$_ } @in; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not @in or grep {not @$_;} @in
MC/DC100%2/2
not @in or grep {not @$_;} @in
not @in
grep {not @$_;} @in
Truth table100%3/3
not(A) or B
A= not @inB= grep {not @$_;} @in
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | my @out = map { $in[$_]->[0] } 0 .. $#in; | |||||||||||||||||||||||||||
| 22 | 3 | my @idx = (0) x @in; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 3 | ▶ | for (my $i = 0; $i >= 0; ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 10 | $sub->(@out); | |||||||||||||||||||||||||||
| 26 | 10 | ▶ | for ($i=$#in; $i >= 0; $i--) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 16 | $idx[$i]++; | |||||||||||||||||||||||||||
| 28 | 16 | ▶ | if ($idx[$i] > $#{$in[$i]}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 9 | $idx[$i] = 0; | |||||||||||||||||||||||||||
| 30 | 9 | $out[$i] = $in[$i]->[0]; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | else { | ||||||||||||||||||||||||||||
| 33 | 7 | $out[$i] = $in[$i]->[$idx[$i]]; | |||||||||||||||||||||||||||
| 34 | 7 | last; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 3 | 1; | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||