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
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# my $catalogue = Math::Values::OeisCatalogue->new(exclude_files=>1); |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package Math::NumSeq::OEIS::Catalogue; |
25
|
2
|
|
|
2
|
|
31
|
use 5.004; |
|
2
|
|
|
|
|
4
|
|
26
|
2
|
|
|
2
|
|
5
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
35
|
|
27
|
2
|
|
|
2
|
|
6
|
use List::Util; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
97
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
30
|
|
|
|
|
|
|
#use Smart::Comments; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
2
|
|
760
|
use Module::Pluggable require => 1; |
|
2
|
|
|
|
|
15160
|
|
|
2
|
|
|
|
|
8
|
|
33
|
|
|
|
|
|
|
my @plugins = sort __PACKAGE__->plugins; |
34
|
|
|
|
|
|
|
### @plugins |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
|
132
|
use vars '$VERSION'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
563
|
|
37
|
|
|
|
|
|
|
$VERSION = 72; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# sub seq_to_num { |
40
|
|
|
|
|
|
|
# my ($class, $num) = @_; |
41
|
|
|
|
|
|
|
# } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub anum_to_info { |
45
|
2
|
|
|
2
|
0
|
3
|
my ($class, $anum) = @_; |
46
|
|
|
|
|
|
|
### Catalogue anum_to_info(): $anum |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
3
|
foreach my $plugin (@plugins) { |
49
|
|
|
|
|
|
|
### $plugin |
50
|
2
|
50
|
|
|
|
13
|
if (my $info = $plugin->anum_to_info($anum)) { |
51
|
2
|
|
|
|
|
6
|
return $info; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
0
|
|
|
|
|
0
|
return undef; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub anum_list { |
58
|
0
|
|
|
0
|
0
|
0
|
my ($class) = @_; |
59
|
0
|
|
|
|
|
0
|
my %ret; |
60
|
0
|
|
|
|
|
0
|
foreach my $plugin (@plugins) { |
61
|
|
|
|
|
|
|
### $plugin |
62
|
0
|
|
|
|
|
0
|
foreach my $info (@{$plugin->info_arrayref}) { |
|
0
|
|
|
|
|
0
|
|
63
|
0
|
|
|
|
|
0
|
$ret{$info->{'anum'}} = 1; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
0
|
my @ret = sort {$a<=>$b} keys %ret; |
|
0
|
|
|
|
|
0
|
|
67
|
0
|
|
|
|
|
0
|
return @ret; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _method_apply { |
71
|
130
|
|
|
130
|
|
110
|
my $acc = shift; |
72
|
130
|
|
|
|
|
107
|
my $method = shift; |
73
|
|
|
|
|
|
|
### plugin anums: map {$_->$method(@_)} @plugins |
74
|
130
|
|
|
|
|
164
|
return $acc->(grep {defined} map {$_->$method(@_)} @plugins); |
|
390
|
|
|
|
|
1091
|
|
|
390
|
|
|
|
|
1211
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
sub anum_after { |
77
|
0
|
|
|
0
|
1
|
0
|
my ($class, $after_anum) = @_; |
78
|
|
|
|
|
|
|
### Catalogue anum_after(): $after_anum |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
_method_apply (\&List::Util::minstr, 'anum_after', $after_anum); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
sub anum_before { |
83
|
0
|
|
|
0
|
1
|
0
|
my ($class, $before_anum) = @_; |
84
|
0
|
|
|
|
|
0
|
_method_apply (\&List::Util::maxstr, 'anum_before', $before_anum); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub anum_first { |
88
|
65
|
|
|
65
|
1
|
59
|
my ($class) = @_; |
89
|
65
|
|
|
|
|
100
|
_method_apply (\&List::Util::minstr, 'anum_first'); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
sub anum_last { |
92
|
65
|
|
|
65
|
1
|
59
|
my ($class) = @_; |
93
|
65
|
|
|
|
|
106
|
_method_apply (\&List::Util::maxstr, 'anum_last'); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# sub anum_to_class { |
98
|
|
|
|
|
|
|
# my ($class, $anum) = @_; |
99
|
|
|
|
|
|
|
# ### anum_to_class(): @_ |
100
|
|
|
|
|
|
|
# my @ret; |
101
|
|
|
|
|
|
|
# foreach my $plugin (@plugins) { |
102
|
|
|
|
|
|
|
# ### $plugin |
103
|
|
|
|
|
|
|
# my $href = $plugin->anum_to_class_hashref; |
104
|
|
|
|
|
|
|
# if (my $aref = $href->{$anum}) { |
105
|
|
|
|
|
|
|
# return @$aref; |
106
|
|
|
|
|
|
|
# } |
107
|
|
|
|
|
|
|
# } |
108
|
|
|
|
|
|
|
# return; |
109
|
|
|
|
|
|
|
# } |
110
|
|
|
|
|
|
|
# |
111
|
|
|
|
|
|
|
# sub _file_anum_list { |
112
|
|
|
|
|
|
|
# my ($class) = @_; |
113
|
|
|
|
|
|
|
# ### anum_list() |
114
|
|
|
|
|
|
|
# my %ret; |
115
|
|
|
|
|
|
|
# foreach my $plugin (@plugins) { |
116
|
|
|
|
|
|
|
# ### $plugin |
117
|
|
|
|
|
|
|
# my $href = $plugin->anum_to_class_hashref; |
118
|
|
|
|
|
|
|
# %ret = (%ret, %$href); |
119
|
|
|
|
|
|
|
# } |
120
|
|
|
|
|
|
|
# return sort keys %ret; |
121
|
|
|
|
|
|
|
# } |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
__END__ |