line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2011, 2012, 2013, 2014 Kevin Ryde |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Math-NumSeq. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Math-NumSeq is free software; you can redistribute it and/or modify |
6
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by the |
7
|
|
|
|
|
|
|
# Free Software Foundation; either version 3, or (at your option) any later |
8
|
|
|
|
|
|
|
# version. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Math-NumSeq is distributed in the hope that it will be useful, but |
11
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
12
|
|
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
13
|
|
|
|
|
|
|
# for more details. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
16
|
|
|
|
|
|
|
# with Math-NumSeq. If not, see . |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Math::NumSeq::OEIS::Catalogue::Plugin; |
19
|
3
|
|
|
3
|
|
43
|
use 5.004; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
105
|
|
20
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
88
|
|
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
3
|
|
14
|
use vars '$VERSION'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1267
|
|
23
|
|
|
|
|
|
|
$VERSION = 71; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
26
|
|
|
|
|
|
|
#use Smart::Comments; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my %anum_to_info_hashref; |
29
|
|
|
|
|
|
|
sub anum_to_info_hashref { |
30
|
3
|
|
|
3
|
0
|
5
|
my ($class) = @_; |
31
|
|
|
|
|
|
|
### anum_to_info_hashref(): $class |
32
|
910
|
|
|
|
|
2523
|
return ($anum_to_info_hashref{$class} ||= |
33
|
3
|
|
100
|
|
|
26
|
{ map { $_->{'anum'} => $_ } @{$class->info_arrayref} }); |
|
1
|
|
|
|
|
13
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub anum_to_info { |
37
|
2
|
|
|
2
|
0
|
4
|
my ($class, $anum) = @_; |
38
|
2
|
100
|
|
|
|
14
|
foreach my $anum ($anum, |
39
|
|
|
|
|
|
|
# A0123456 shortened to A123456 |
40
|
|
|
|
|
|
|
($anum =~ /A0(\d{6})/ ? "A$1" : ())) { |
41
|
3
|
|
100
|
|
|
11
|
return ($class->anum_to_info_hashref->{$anum} || next); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub anum_after { |
46
|
130
|
|
|
130
|
0
|
232
|
my ($class, $after_anum) = @_; |
47
|
|
|
|
|
|
|
### $after_anum |
48
|
130
|
|
|
|
|
208
|
my $ret; |
49
|
130
|
|
|
|
|
209
|
foreach my $info (@{$class->info_arrayref}) { |
|
130
|
|
|
|
|
733
|
|
50
|
|
|
|
|
|
|
### after info: $info |
51
|
59150
|
100
|
100
|
|
|
335873
|
if ($info->{'anum'} gt $after_anum |
|
|
|
33
|
|
|
|
|
52
|
|
|
|
|
|
|
&& (! defined $ret || $ret gt $info->{'anum'})) { |
53
|
390
|
|
|
|
|
775
|
$ret = $info->{'anum'}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
130
|
|
|
|
|
1123
|
return $ret; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
sub anum_before { |
59
|
130
|
|
|
130
|
0
|
213
|
my ($class, $before_anum) = @_; |
60
|
|
|
|
|
|
|
### $before_anum |
61
|
130
|
|
|
|
|
156
|
my $ret; |
62
|
130
|
|
|
|
|
233
|
foreach my $info (@{$class->info_arrayref}) { |
|
130
|
|
|
|
|
825
|
|
63
|
59150
|
100
|
100
|
|
|
394114
|
if ($info->{'anum'} lt $before_anum |
|
|
|
33
|
|
|
|
|
64
|
|
|
|
|
|
|
&& (! defined $ret || $ret lt $info->{'anum'})) { |
65
|
520
|
|
|
|
|
1002
|
$ret = $info->{'anum'}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
130
|
|
|
|
|
1235
|
return $ret; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub anum_first { |
72
|
195
|
|
|
195
|
0
|
394
|
my ($class) = @_; |
73
|
195
|
|
|
|
|
1066
|
return $class->anum_after ('A000000'); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
sub anum_last { |
76
|
195
|
|
|
195
|
0
|
457
|
my ($class) = @_; |
77
|
195
|
|
|
|
|
1178
|
return $class->anum_before('A9999999'); # 7-digits |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
__END__ |