NumSeq/OEIS.pm

filter: Statementstmt 92.1% 35 / 38 Branchbran 50.0% 2 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 90.0% 9 / 10 Podpod 100% 3 / 3 totaltotal 86.2% 50 / 58 CC 4 SCAR 7.2
CC
4
Cov
86%
new
4.2
oeis_anum
2.0
BEGIN
1.0
CRAP 2.1
« NumSeq/PrimeIndexOrder.pm ↑ Summary NumSeq/Triangular.pm »
1 # Copyright 2011, 2012, 2013, 2014, 2016, 2018, 2019, 2020 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 <http://www.gnu.org/licenses/>.
17  
18 package Math::NumSeq::OEIS;
19 2 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 2 ▶use vars '$VERSION','@ISA';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 2 $VERSION = 75;
25  
26 2 ▶use Math::NumSeq;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 2 @ISA = ('Math::NumSeq');
28  
29 # uncomment this to run the ### lines
30 #use Smart::Comments;
31  
32  
33 # use constant name => Math::NumSeq::__('OEIS');
34 2 ▶use constant description => Math::NumSeq::__('OEIS sequence, by its A-number. There\'s code for some sequences, others look in ~/OEIS directory for downloaded files A123456.internal, A123456.html and/or b123456.txt.');
Subroutine BEGIN: called CC=1 SCAR=0.0
35 2 ▶use constant characteristic_integer => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
36  
37 # recalculated each time for updated file min/max
38 65 ▶sub parameter_info_array {
Subroutine parameter_info_array: called CC=1 SCAR=0.0
Pod documented
39 65 require Math::NumSeq::OEIS::Catalogue;
40 return [
41 65 { name => 'anum',
42 type => 'string',
43 display => Math::NumSeq::__('OEIS A-number'),
44 type_hint => 'oeis_anum',
45 width => 8,
46 minimum => Math::NumSeq::OEIS::Catalogue->anum_first,
47 maximum => Math::NumSeq::OEIS::Catalogue->anum_last,
48 default => 'A000290', # Squares, an arbitrary choice
49 },
50 ];
51 }
52 ### parameter_info_array parameter_info_array()
53  
54 0 ▶sub oeis_anum {
Subroutine oeis_anum: not called CC=1 SCAR=6.9
Pod documented
55 0 my ($self) = @_;
56 0 return $self->{'oeis_anum'};
57 }
58  
59 2 ▶sub new {
Subroutine new: called CC=4 SCAR=14.4
Pod documented
60 2 my ($class, %options) = @_;
61 ### Values-OEIS: @_
62  
63 2 my $anum = $options{'anum'};
64 2 ▶ if (! defined $anum) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $anum) 0 2 2
65 0 $anum = parameter_info_array()->[0]->{'default'};
66 }
67 ### $anum
68  
69 2 require Math::NumSeq::OEIS::Catalogue;
70 2 ▶ my $info = Math::NumSeq::OEIS::Catalogue->anum_to_info($anum)
Condition50%1/2
'Math::NumSeq::OEIS::Catalogue'->anum_to_info($anum) || croak('No data for OEIS sequence ', $anum)
l!l
20
MC/DC0%0/1
'Math::NumSeq::OEIS::Catalogue'->anum_to_info($anum) || croak('No data for OEIS sequence ', $anum)
'Math::NumSeq::OEIS::Catalogue'->anum_to_info($anum)
Truth table50%1/2
A
A= 'Math::NumSeq::OEIS::Catalogue'->anum_to_info($anum)
Aresult
11
00
71 || croak 'No data for OEIS sequence ',$anum;
72 ### $info
73  
74 2 my $numseq_class = $info->{'class'};
75 2 my $parameters = $info->{'parameters'};
76 2 require Module::Load;
77 2 Module::Load::load($numseq_class);
78 2 ▶ return $numseq_class->new (%options, ($parameters ? @$parameters : ()));
Branch: 1 branch
BranchTrueFalseTotal
$parameters ? : 0 2 2
79 }
80  
81 2 1;
82 __END__
« NumSeq/PrimeIndexOrder.pm ↑ Summary NumSeq/Triangular.pm »