The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Math::OEIS::Stripped - read the OEIS stripped file

SYNOPSIS

 my @values = Math::OEIS::Stripped->anum_to_values('A123456');

DESCRIPTION

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).

Terms of use for the stripped file data can be found at (Creative Commons Attribution Non-Commercial 3.0, at the time of writing).

FUNCTIONS

@values = Math::OEIS::Stripped->anum_to_values($anum)
$str = Math::OEIS::Stripped->anum_to_values_str($anum)

Return the values from the stripped file for an $anum 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 usual Perl integer are automatically converted to Math::BigInt so as to preserve exact values.

anum_to_values_str() returns a string like "1,2,3,4", or undef if 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 split or similar.

Draft sequences may have an empty values list ",,". The return for them is the same as "no such A-number" reckoning they have no values yet.

Math::OEIS::Stripped->close()

Close the stripped file handle, if not already closed.

Oopery

$obj = Math::OEIS::Stripped->new (key => value, ...)

Create and return a new Math::OEIS::Stripped object to read an OEIS stripped file. The optional key/value parameters can be

    filename => $filename         default ~/OEIS/stripped
    fh       => $filehandle

The default filename is ~/OEIS/stripped, or other directory per Math::OEIS->local_directories(). A different filename can be given, or an open filehandle. When a file handle is given the filename may be used for diagnostics and so can be helpfully given too.

@values = $obj->anum_to_values($anum)
$str = $obj->anum_to_values_str($anum)

Return the values from the stripped file for an $anum string such as "A000001" (as per above).

$filename = $obj->filename()

Return the filename from $obj.

$filename = Math::OEIS::Stripped->default_filename()
$filename = $obj->default_filename()

Return the default filename which is used if no filename or fh option is given. default_filename() can be called either as a class method or object method.

$obj->close()

Close the stripped file handle, if not already closed.

SEE ALSO

Math::OEIS, Math::OEIS::Names

OEIS files page http://oeis.org/allfiles.html

HOME PAGE

http://user42.tuxfamily.org/math-oeis/index.html

LICENSE

Copyright 2010, 2011, 2012, 2013, 2014, 2015 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/.