NAME

Math::OEIS::Grep - search for numbers in OEIS stripped file

SYNOPSIS

use Math::OEIS::Grep;
Math::OEIS::Grep->search (array => [ 8,13,21,34,55,89 ]);
# prints matches found

# command line
# perl -MMath::OEIS::Grep=-search,123,456,789

DESCRIPTION

This module searches a downloaded copy of the OEIS stripped file for numbers.

    ~/OEIS/stripped

The stripped file is the first few sample values of all OEIS sequences. This grep is an alternative to the OEIS web site search and is good if offline or for mechanically trying a large numbers of searches.

The exact form of the results printout and transformations is not settled. The intention is to do something sensible to find given numbers.

The OEIS names file, if available, is used to show the name of a matched sequence (see Math::OEIS::Names).

Details

A long array of values which might goes past the OEIS samples is still matched. This works by demanding a match of the first few array values but then stopping when either the end of the array or the end of the samples, whichever comes first.

An array of constant values or small constant difference is recognised and not searched, since there's usually too many matches and the OEIS sequence which is a constant or constant difference may not be the first match.

File::Map is used to mmap the stripped file into core for searching, if that module is available. This is recommended since mmap is a speedup of about 2x over the fallback plain reading (by blocks).

FUNCTIONS

Math::OEIS::Grep->search (array => $aref, ...)

Print matches of the given array values in the OEIS stripped file. The key/value pairs can be

array       => $arrayref (mandatory)
name        => $string
max_matches => $integer (default 10)

array is an arrayref of values to search for. This parameter must be given.

name is printed if matches are found. When doing many searches this identify which one has matched. Eg.

name => "case d=123",

max_matches limits the number of sequences returned. This is intended as a protection against a large number of matches from some small list or frequently occurring values.

COMMAND LINE

The module import accepts a -search option which is designed for use from the command line

perl -MMath::OEIS::Grep=-search,123,456,789

SEE ALSO

Math::OEIS, Math::OEIS::Stripped, File::Map

HOME PAGE

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

LICENSE

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