Math-OEIS

 view release on metacpan or  search on metacpan

examples/grep-not-in-oeis.pl  view on Meta::CPAN

# machine-readable form so can grep in the future to see if they or
# something close has been added.
#
# Numbers should be separated by commas.  Spaces are optional.
#
# Sequences which match but you know are false (become different later, only
# a middle match, close but not quite what you want, etc) can be excluded by
# further "not" lines like
#
#     # not in OEIS: 17238, 12783, 4839, 589
#     # not A123456 as its formula is different after 200 terms
#     # not A000006 which begins differently
#
# This program is an example of using Math::OEIS::Grep in a mechanical way.
# The "not A123456" lines become its "exclude_list".  Perhaps some
# additional hints or exclusions will be possible in the future, eg. values
# range.
#
# The results printed are a bit rough and are intended for human readers so
# may change a little or a lot.  But the "not in OEIS" lines grepped from
# the files should be settled.

examples/grep-not-in-oeis.pl  view on Meta::CPAN

    ### @values
    foreach my $value (@values) {
      unless ($value =~ /^(-?[1-9][0-9]*|0)$/) {
        print "$filename:$linenum: bad value \"$value\" in \"$values\"\n";
        exit 1;
      }
    }

    {
      # Notice duplicate searches, which can be due to too much cut and
      # paste, or sometimes an unnoticed relationship between formulas etc.
      # Those on immediately following lines are ok, being some subset
      # search.
      my $str = join(',',@values);
      foreach my $seen (reverse @seen) {  # reverse for most recent first
        my $seen_str = $seen->{'str'};
        my $len = min(length($str),length($seen_str));
        if (index($str,$seen_str)>=0 || index($seen_str,$str)>=0) {
          last if ($filename eq $seen->{'filename'}   # close previous
                   && abs($linenum - $seen->{'linenum'}) <= 2);
          print "$filename:$linenum: duplicate",



( run in 0.262 second using v1.01-cache-2.11-cpan-26ccb49234f )