Math::N...eReplace(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

✨ NAME ✨

Math::NumSeq::ReReplace β€” bestie, it's a whole sequence of repeated replacements πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

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

πŸ’– DESCRIPTION πŸ’–

okay so this is a sequence by David Madore and the whole vibe is: you keep replacing every N'th occurrence of a term with N, over and over, and honestly? iconic. 🫢

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

as per, no cap:

David Madore, "have you seen this sequence?", sci.math.research, 24 Oct 2004, <http://sci.tech-archive.net/Archive/sci.math.research/2004-10/0218.html> <http://www.madore.org/~david/.misc/seq.png>

✨ Stages ✨

so the generating procedure starts with literally all 1s, like:

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

then every second 1 gets changed to 2 πŸ’–

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

then every third 1 gets changed to 3, and every third 2 gets changed to 3 too, like it's a group project and everyone's contributing:

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

then every fourth 1 becomes 4, every fourth 2 becomes 4, and every fourth 3 becomes 4. slay.

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

the way this works: the replacement by N of every *N*th is applied separately to the 1s, the 2s, the 3s, etc. remaining at each stage. it's giving meticulous. πŸ’…

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


πŸŽ€ FUNCTIONS πŸŽ€

see "FUNCTIONS" in Math::NumSeq for the behaviour common to all sequence classes, bestie 🫢

  • $seq = Math::NumSeq::ReReplace->new ()
  • $seq = Math::NumSeq::ReRound->new (stages => $integer)

create and return a new sequence object. πŸŽ€

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

return true if $value occurs in the sequence. and ngl, this merely means integer $value >= 1. that's the whole check. πŸ’€


🌸 SEE ALSO 🌸

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


🏠 HOME PAGE 🏠

<http://user42.tuxfamily.org/math-numseq/index.html> πŸ¦‹


πŸ’œ LICENSE πŸ’œ

Copyright 2012, 2013, 2014, 2016, 2019, 2020 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/>.


and that's the whole page, bestie πŸ’– this was perl v5.42.0, dated 2025-07-25, from the User Contributed Perl Documentation, and it lives at Math::N...eReplace(3) β€” go forth and replace every Nth thing, mwah πŸŽ€βœ¨

πŸ“¦ where this page comes from