The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::ReReplace -- sequence of repeated replacements

SYNOPSIS

 use Math::NumSeq::ReReplace;
 my $seq = Math::NumSeq::ReReplace->new;
 my ($i, $value) = $seq->next;

DESCRIPTION

This is a sequence by David Madore formed by repeatedly replacing every N'th occurrence of a term with N.

    1, 2, 1, 2, 3, 3, 1, 2, 4, 4, 3, 4, ...

Stages

The optional stage => $n parameter limits the replacements to a given number of stages of the algorithm. The default -1 means unlimited.

The generating procedure begins with all 1s,

    stage 0: 1,1,1,1,1,1,1,1,1,1,1,1,...

Then every second 1 is changed to 2

    stage 1: 1,2,1,2,1,2,1,2,1,2,1,2,...

Then every third 1 is changed to 3, and every third 2 changed to 3 also,

    stage 2: 1,2,1,2,3,3,1,2,1,2,3,3,...

Then every fourth 1 becomes 4, fourth 2 becomes 4, fourth 3 becomes 4.

    stage 3: 1,2,1,2,3,3,1,2,4,4,3,4,...

The replacement of N at every Nth is applied separately to the 1s, 2s, 3s etc remaining at each stage.

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

$seq = Math::NumSeq::ReReplace->new ()

Create and return a new sequence object.

$bool = $seq->pred($value)

Return true if $value occurs in the sequence. This merely means integer $value >= 1.

SEE ALSO

Math::NumSeq, Math::NumSeq::ReRound

HOME PAGE

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

LICENSE

Copyright 2012 Kevin Ryde

Math-NumSeq 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-NumSeq 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-NumSeq. If not, see <http://www.gnu.org/licenses/>.