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
|
|
61
|
use 5.004; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
78
|
|
26
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
65
|
|
27
|
2
|
|
|
2
|
|
11
|
use List::Util; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
140
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
30
|
|
|
|
|
|
|
#use Smart::Comments; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
2
|
|
2481
|
use Module::Pluggable require => 1; |
|
2
|
|
|
|
|
42649
|
|
|
2
|
|
|
|
|
12
|
|
33
|
|
|
|
|
|
|
my @plugins = sort __PACKAGE__->plugins; |
34
|
|
|
|
|
|
|
### @plugins |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
2
|
|
232
|
use vars '$VERSION'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
782
|
|
37
|
|
|
|
|
|
|
$VERSION = 71; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# sub seq_to_num { |
40
|
|
|
|
|
|
|
# my ($class, $num) = @_; |
41
|
|
|
|
|
|
|
# } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub anum_to_info { |
45
|
2
|
|
|
2
|
0
|
4
|
my ($class, $anum) = @_; |
46
|
|
|
|
|
|
|
### Catalogue anum_to_info(): $anum |
47
|
|
|
|
|
|
|
|
48
|
2
|
|
|
|
|
4
|
foreach my $plugin (@plugins) { |
49
|
|
|
|
|
|
|
### $plugin |
50
|
2
|
50
|
|
|
|
23
|
if (my $info = $plugin->anum_to_info($anum)) { |
51
|
2
|
|
|
|
|
11
|
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
|
|
214
|
my $acc = shift; |
72
|
130
|
|
|
|
|
227
|
my $method = shift; |
73
|
|
|
|
|
|
|
### plugin anums: map {$_->$method(@_)} @plugins |
74
|
130
|
|
|
|
|
249
|
return $acc->(grep {defined} map {$_->$method(@_)} @plugins); |
|
390
|
|
|
|
|
3692
|
|
|
390
|
|
|
|
|
5806
|
|
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
|
144
|
my ($class) = @_; |
89
|
65
|
|
|
|
|
252
|
_method_apply (\&List::Util::minstr, 'anum_first'); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
sub anum_last { |
92
|
65
|
|
|
65
|
1
|
180
|
my ($class) = @_; |
93
|
65
|
|
|
|
|
353
|
_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__ |