| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Complete::Number; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-09-03'; # DATE |
|
4
|
|
|
|
|
|
|
our $VERSION = '0.02'; # VERSION |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
608
|
use 5.010001; |
|
|
1
|
|
|
|
|
3
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
17
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
|
|
#use experimental 'smartmatch'; |
|
10
|
|
|
|
|
|
|
#use Log::Any::IfLOG '$log'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
3363
|
use Complete; |
|
|
1
|
|
|
|
|
262
|
|
|
|
1
|
|
|
|
|
1271
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Exporter; |
|
15
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
17
|
|
|
|
|
|
|
complete_int |
|
18
|
|
|
|
|
|
|
complete_float |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
our %SPEC; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$SPEC{':package'} = { |
|
23
|
|
|
|
|
|
|
v => 1.1, |
|
24
|
|
|
|
|
|
|
summary => 'Complete numbers', |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my %common_args = ( |
|
28
|
|
|
|
|
|
|
word => { schema=>[str=>{default=>''}], pos=>0, req=>1 }, |
|
29
|
|
|
|
|
|
|
ci => { schema=>['bool'] }, |
|
30
|
|
|
|
|
|
|
); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$SPEC{complete_int} = { |
|
33
|
|
|
|
|
|
|
v => 1.1, |
|
34
|
|
|
|
|
|
|
summary => 'Complete integer number', |
|
35
|
|
|
|
|
|
|
args => { |
|
36
|
|
|
|
|
|
|
%common_args, |
|
37
|
|
|
|
|
|
|
max => { schema=>['int'] }, |
|
38
|
|
|
|
|
|
|
min => { schema=>['int'] }, |
|
39
|
|
|
|
|
|
|
xmax => { schema=>['int'] }, |
|
40
|
|
|
|
|
|
|
xmin => { schema=>['int'] }, |
|
41
|
|
|
|
|
|
|
}, |
|
42
|
|
|
|
|
|
|
result_naked => 1, |
|
43
|
|
|
|
|
|
|
result => { |
|
44
|
|
|
|
|
|
|
schema => 'array', |
|
45
|
|
|
|
|
|
|
}, |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
|
|
|
|
|
|
sub complete_int { |
|
48
|
4
|
|
|
4
|
1
|
4194
|
require Complete::Util; |
|
49
|
|
|
|
|
|
|
|
|
50
|
4
|
|
|
|
|
2829
|
my %args = @_; |
|
51
|
4
|
|
100
|
|
|
20
|
my $word = $args{word} // ""; |
|
52
|
4
|
|
33
|
|
|
14
|
my $ci = $args{ci} // $Complete::OPT_CI; |
|
53
|
|
|
|
|
|
|
|
|
54
|
4
|
|
|
|
|
5
|
my @words; |
|
55
|
|
|
|
|
|
|
|
|
56
|
4
|
|
|
|
|
6
|
my $limit = 100; |
|
57
|
4
|
100
|
66
|
|
|
84
|
if(defined($args{min}) && defined($args{max}) && |
|
|
|
50
|
66
|
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
|
|
|
100
|
33
|
|
|
|
|
|
|
|
50
|
66
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$args{max}-$args{min} <= $limit) { |
|
59
|
1
|
|
|
|
|
4
|
push @words, $args{min} .. $args{max}; |
|
60
|
|
|
|
|
|
|
} elsif (defined($args{min}) && defined($args{xmax}) && |
|
61
|
|
|
|
|
|
|
$args{xmax}-$args{min} <= $limit) { |
|
62
|
0
|
|
|
|
|
0
|
push @words, $args{min} .. $args{xmax}-1; |
|
63
|
|
|
|
|
|
|
} elsif (defined($args{xmin}) && defined($args{max}) && |
|
64
|
|
|
|
|
|
|
$args{max}-$args{xmin} <= $limit) { |
|
65
|
0
|
|
|
|
|
0
|
push @words, $args{xmin}+1 .. $args{max}; |
|
66
|
|
|
|
|
|
|
} elsif (defined($args{xmin}) && defined($args{xmax}) && |
|
67
|
|
|
|
|
|
|
$args{xmax}-$args{xmin} <= $limit) { |
|
68
|
1
|
|
|
|
|
3
|
push @words, $args{xmin}+1 .. $args{xmax}-1; |
|
69
|
|
|
|
|
|
|
} elsif (length($word) && $word !~ /\A-?\d*\z/) { |
|
70
|
|
|
|
|
|
|
# warn: not an int |
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
|
|
|
|
|
|
# do a digit by digit completion |
|
73
|
2
|
|
|
|
|
4
|
my @signs = (""); |
|
74
|
2
|
100
|
|
|
|
10
|
push @signs, "-" if $word =~ /\A-|\A\z/; |
|
75
|
2
|
|
|
|
|
4
|
for my $sign (@signs) { |
|
76
|
3
|
|
|
|
|
6
|
for ("", 0..9) { |
|
77
|
33
|
|
|
|
|
55
|
my $i = $sign . $word . $_; |
|
78
|
33
|
100
|
|
|
|
65
|
next unless length $i; |
|
79
|
32
|
100
|
|
|
|
96
|
next unless $i =~ /\A-?\d+\z/; |
|
80
|
31
|
100
|
|
|
|
57
|
next if $i eq '-0'; |
|
81
|
30
|
50
|
|
|
|
64
|
next if $i =~ /\A-?0\d/; |
|
82
|
30
|
50
|
33
|
|
|
66
|
next if defined($args{min} ) && $i < $args{min}; |
|
83
|
30
|
50
|
33
|
|
|
67
|
next if defined($args{xmin}) && $i <= $args{xmin}; |
|
84
|
30
|
50
|
33
|
|
|
66
|
next if defined($args{max} ) && $i > $args{max}; |
|
85
|
30
|
50
|
33
|
|
|
63
|
next if defined($args{xmin}) && $i >= $args{xmax}; |
|
86
|
30
|
|
|
|
|
63
|
push @words, $i; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
4
|
|
|
|
|
12
|
Complete::Util::complete_array_elem(array=>\@words, word=>$word, ci=>$ci); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
$SPEC{complete_float} = { |
|
95
|
|
|
|
|
|
|
v => 1.1, |
|
96
|
|
|
|
|
|
|
summary => 'Complete floating number', |
|
97
|
|
|
|
|
|
|
args => { |
|
98
|
|
|
|
|
|
|
%common_args, |
|
99
|
|
|
|
|
|
|
max => { schema=>['float'] }, |
|
100
|
|
|
|
|
|
|
min => { schema=>['float'] }, |
|
101
|
|
|
|
|
|
|
xmax => { schema=>['float'] }, |
|
102
|
|
|
|
|
|
|
xmin => { schema=>['float'] }, |
|
103
|
|
|
|
|
|
|
}, |
|
104
|
|
|
|
|
|
|
result_naked => 1, |
|
105
|
|
|
|
|
|
|
result => { |
|
106
|
|
|
|
|
|
|
schema => 'array', |
|
107
|
|
|
|
|
|
|
}, |
|
108
|
|
|
|
|
|
|
}; |
|
109
|
|
|
|
|
|
|
sub complete_float { |
|
110
|
1
|
|
|
1
|
1
|
2028
|
require Complete::Util; |
|
111
|
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
4
|
my %args = @_; |
|
113
|
1
|
|
50
|
|
|
7
|
my $word = $args{word} // ""; |
|
114
|
1
|
|
33
|
|
|
5
|
my $ci = $args{ci} // $Complete::OPT_CI; |
|
115
|
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
2
|
my @words; |
|
117
|
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
2
|
my $limit = 100; |
|
119
|
|
|
|
|
|
|
|
|
120
|
1
|
50
|
33
|
|
|
6
|
if (length($word) && $word !~ /\A-?\d*(\.\d*)?\z/) { |
|
121
|
|
|
|
|
|
|
# warn: not a float |
|
122
|
|
|
|
|
|
|
} else { |
|
123
|
1
|
|
|
|
|
2
|
my @signs = (""); |
|
124
|
1
|
50
|
|
|
|
7
|
push @signs, "-" if $word =~ /\A-|\A\z/; |
|
125
|
1
|
|
|
|
|
2
|
for my $sign (@signs) { |
|
126
|
2
|
|
|
|
|
5
|
for ("", 0..9, |
|
127
|
|
|
|
|
|
|
".0",".1",".2",".3",".4",".5",".6",".7",".8",".9") { |
|
128
|
42
|
|
|
|
|
84
|
my $f = $sign . $word . $_; |
|
129
|
42
|
100
|
|
|
|
78
|
next unless length $f; |
|
130
|
41
|
100
|
|
|
|
125
|
next unless $f =~ /\A-?\d+(\.\d+)?\z/; |
|
131
|
20
|
100
|
|
|
|
40
|
next if $f eq '-0'; |
|
132
|
19
|
50
|
|
|
|
33
|
next if $f =~ /\A-?0\d\z/; |
|
133
|
19
|
50
|
33
|
|
|
45
|
next if defined($args{min} ) && $f < $args{min}; |
|
134
|
19
|
50
|
33
|
|
|
38
|
next if defined($args{xmin}) && $f <= $args{xmin}; |
|
135
|
19
|
50
|
33
|
|
|
40
|
next if defined($args{max} ) && $f > $args{max}; |
|
136
|
19
|
50
|
33
|
|
|
41
|
next if defined($args{xmin}) && $f >= $args{xmax}; |
|
137
|
19
|
|
|
|
|
34
|
push @words, $f; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
3
|
Complete::Util::complete_array_elem(array=>\@words, word=>$word, ci=>$ci); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |
|
147
|
|
|
|
|
|
|
# ABSTRACT: Complete numbers |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__END__ |