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