Math::OEIS::Stripped - read the OEIS stripped file
my @values = Math::OEIS::Stripped->anum_to_values('A123456');
This is an interface to the big OEIS stripped file. The file should be downloaded and unzipped to ~/OEIS/stripped,
cd ~/OEIS wget http://oeis.org/stripped.gz gunzip stripped.gz
stripped is a very large file containing each A-number and its sample values. There's usually about 180 characters worth of sample values but possibly less or more.
The stripped file is sorted by A-number so
anum_to_values() is a text file binary search (currently implemented with Search::Dict).
@values = Math::OEIS::Stripped->anum_to_values($anum)
$values_str = Math::OEIS::Stripped->anum_to_values_str($anum)
Return the values from the stripped file for
$anum(a string) such as "A000001".
anum_to_values()returns a list of values, or an empty list if no such A-number.
Values bigger than a Perl integer are converted to
Math::BigIntso as to be exact in numeric operations, such as comparisons
anum_to_values_str()returns a string like "1,2,3,4", or
undefif no such A-number. The stripped file has leading and trailing commas on its values list but these are removed here for convenience of subsequent
In the past, draft sequences were in the stripped with an empty values list ",,". The return for them is an empty list (meaning no values yet).
If running in
perl -Ttaint mode then
$values_strand each value string in
@valuesis tainted in the usual way for reading from a file. Values converted to
Math::BigIntdo not keep a notion of taintedness, but
Math::BigIntshould validate as digits which is in the spirit of untainting after checking.
Close the stripped file handle, or do nothing if already closed or never opened.
$obj = Math::OEIS::Stripped->new (key => value, ...)
Create and return a new
Math::OEIS::Strippedobject to read an OEIS stripped file. The optional key/value parameters can be
filename => $filename # default ~/OEIS/stripped fh => $filehandle use_bigint => string "if_necessary", # default 0, # never 1, # always bigint_class => $classname # default "Math::BigInt"
filenamedefaults to ~/OEIS/stripped per
Math::OEIS->local_directories(). Another filename can be given, or an open filehandle. If a handle is given then
filenameis used in diagnostics so can be given too.
use_bigintcontrols conversion of values to bignum objects in
"if_necessary"converts values bigger than a Perl integer, or option 1 or 0 for always or never convert. When not converted, each value is a string suitable for any string operation but possibly not numeric operations.
bigint_classis the module name for bignum conversion. It is loaded with
requirewhen needed and values are created by
$classname->new("123"). If the class has runtime options, such as the choice of back-ends in
Math::BigInt, then they should be setup in mainline code.
@values = $obj->anum_to_values($anum)
$values_str = $obj->anum_to_values_str($anum)
Return the values from the stripped file for an
$anumstring such as "A000001", like the class method described above (but with
$filename = $obj->filename()
Return the filename from
$filename = Math::OEIS::Stripped->default_filename()
$filename = $obj->default_filename()
Return the default filename which is used if no
fhoption is given.
default_filename()can be called either as a class method or object method.
Close the stripped file handle, or do nothing if already closed.
($anum,$values_str) = Math::OEIS::Stripped->line_split_anum($line)
Split a line of the stripped file into A-number and values string.
$lineshould be like
Leading and trailing comma (and any trailing newline) are discarded so
$values_stris like "1,2,3".
$lineis not A-number and values like this then return an empty list. The stripped file starts with some comment lines (
#) and they get this empty return.
In the past, draft sequences were included in the stripped file with empty values list. They are reckoned non-lines since no values, so an empty return.
@values = Math::OEIS::Stripped->values_split($values_str)
@values = $obj->values_split($values_str)
$values_stris a string of integers and commas like "123,-456,789". Return them split to a list of integers.
split()on commas, and apply the
use_bigintoption to the result. See
new()above about that option.
OEIS files page http://oeis.org/allfiles.html
Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020 Kevin Ryde
Math-OEIS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-OEIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-OEIS. If not, see http://www.gnu.org/licenses/.