line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package List::Utils::MoveElement::PP; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
81443
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
6
|
|
|
|
|
|
|
our @VERSION = 0.01; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use Carp qw/croak/; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
409
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub to_beginning { |
11
|
6
|
|
|
6
|
0
|
22
|
my ($i, @array) = @_; |
12
|
6
|
50
|
33
|
|
|
31
|
croak 'Usage: to_beginning($n, @list)' if !defined($i) or !@array; |
13
|
6
|
50
|
|
|
|
14
|
croak 'Array index out of range' if $i > $#array; |
14
|
6
|
100
|
|
|
|
21
|
return @array if $i == 0; #no-op |
15
|
5
|
|
|
|
|
57
|
return @array[$i, 0 .. $i-1, $i+1 .. $#array]; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub to_end { |
19
|
6
|
|
|
6
|
0
|
25
|
my ($i, @array) = @_; |
20
|
6
|
50
|
33
|
|
|
38
|
croak 'Usage: to_end($n, @list)' if !defined($i) or !@array; |
21
|
6
|
50
|
|
|
|
15
|
croak 'Array index out of range' if $i > $#array; |
22
|
6
|
100
|
|
|
|
21
|
return @array if $i == $#array; #no-op |
23
|
5
|
|
|
|
|
73
|
return @array[0 .. $i-1, $i+1 .. $#array, $i]; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub left { |
27
|
6
|
|
|
6
|
0
|
139
|
my ($i, @array) = @_; |
28
|
6
|
50
|
33
|
|
|
34
|
croak 'Usage: move_left($n, @list)' if !defined($i) or !@array; |
29
|
6
|
50
|
|
|
|
16
|
croak 'Array index out of range' if $i > $#array; |
30
|
6
|
100
|
|
|
|
29
|
return @array if $i == 0; #no-op |
31
|
5
|
|
|
|
|
15
|
($array[$i-1], $array[$i]) = ($array[$i], $array[$i-1]); |
32
|
5
|
|
|
|
|
46
|
return @array; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub right { |
36
|
6
|
|
|
6
|
0
|
22
|
my ($i, @array) = @_; |
37
|
6
|
50
|
33
|
|
|
30
|
croak 'Usage: move_left($n, @list)' if !defined($i) or !@array; |
38
|
6
|
50
|
|
|
|
16
|
croak 'Array index out of range' if $i > $#array; |
39
|
6
|
100
|
|
|
|
62
|
return @array if $i == $#array; #no-op |
40
|
5
|
|
|
|
|
16
|
($array[$i+1], $array[$i]) = ($array[$i], $array[$i+1]); |
41
|
5
|
|
|
|
|
51
|
return @array; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |