line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Kevin Ryde |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Math-OEIS. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Math-OEIS is free software; you can redistribute it and/or modify it |
6
|
|
|
|
|
|
|
# under the terms of the GNU General Public License as published by the Free |
7
|
|
|
|
|
|
|
# Software Foundation; either version 3, or (at your option) any later |
8
|
|
|
|
|
|
|
# version. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Math-OEIS 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-OEIS. If not, see . |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Math::OEIS::Names; |
19
|
3
|
|
|
3
|
|
73113
|
use 5.006; |
|
3
|
|
|
|
|
16
|
|
20
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
59
|
|
21
|
3
|
|
|
3
|
|
10
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
82
|
|
22
|
3
|
|
|
3
|
|
12
|
use Carp 'croak'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
127
|
|
23
|
|
|
|
|
|
|
|
24
|
3
|
|
|
3
|
|
1015
|
use Math::OEIS::SortedFile; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
170
|
|
25
|
|
|
|
|
|
|
our @ISA = ('Math::OEIS::SortedFile'); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
28
|
|
|
|
|
|
|
# use Smart::Comments; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = 13; |
31
|
|
|
|
|
|
|
|
32
|
3
|
|
|
3
|
|
18
|
use constant base_filename => 'names'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
564
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub line_split { |
35
|
4
|
|
|
4
|
1
|
1961
|
my ($self, $line) = @_; |
36
|
|
|
|
|
|
|
### Names line_split(): $line |
37
|
4
|
100
|
|
|
|
20
|
$line =~ /^((A\d+)\s*)(.*)/ |
38
|
|
|
|
|
|
|
or return; # perhaps comment lines |
39
|
3
|
|
|
|
|
20
|
return (substr($line,0,length($2)), |
40
|
|
|
|
|
|
|
substr($line,length($1),length($3))); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use constant::defer _HAVE_ENCODE => sub { |
44
|
1
|
50
|
|
|
|
19
|
eval { require Encode; 1 } || 0; |
|
1
|
|
|
|
|
463
|
|
|
1
|
|
|
|
|
8262
|
|
45
|
3
|
|
|
3
|
|
1277
|
}; |
|
3
|
|
|
|
|
2015
|
|
|
3
|
|
|
|
|
34
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub anum_to_name { |
48
|
1
|
|
|
1
|
1
|
5
|
my ($self, $anum) = @_; |
49
|
|
|
|
|
|
|
### Names anum_to_name(): $anum |
50
|
1
|
|
|
|
|
6
|
my $line = $self->anum_to_line($anum); |
51
|
1
|
50
|
|
|
|
4
|
if (! defined $line) { return undef; } |
|
0
|
|
|
|
|
0
|
|
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
2
|
my ($got_anum, $name) = $self->line_split($line); |
54
|
1
|
50
|
|
|
|
4
|
if ($got_anum ne $anum) { return undef; } |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
|
56
|
1
|
50
|
|
|
|
4
|
if (_HAVE_ENCODE) { |
57
|
1
|
|
|
|
|
39
|
$name = Encode::decode('utf8', $name, Encode::FB_PERLQQ()); |
58
|
|
|
|
|
|
|
} |
59
|
1
|
|
|
|
|
39
|
return $name; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# sub anum_to_name { |
64
|
|
|
|
|
|
|
# my ($class, $anum) = @_; |
65
|
|
|
|
|
|
|
# $anum =~ /^A[0-9]+$/ or die "Bad A-number: ", $anum; |
66
|
|
|
|
|
|
|
# return `zgrep -e ^$anum $ENV{HOME}/OEIS/names.gz`; |
67
|
|
|
|
|
|
|
# } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
__END__ |