Math::NumSeq::Runs(3)

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

🌸 NAME 🌸

Math::NumSeq::Runs β€” runs of consecutive integers πŸ’« (yes bestie, it's exactly what it sounds like)


✨ SYNOPSIS ✨

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

like. five lines. that's the whole vibe. go off πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this is a whole family of sequences and they're ALL just "runs of integers" but styled differently πŸ’– The runs_type parameter β€” it's a string btw, not a number, don't come for me β€” can be any of these:

  • "0toN" β€” 0, 0,1, 0,1,2, 0,1,2,3, etc β€” runs 0..N
  • "1toN" β€” 1, 1,2, 1,2,3, 1,2,3,4, etc β€” runs 1..N
  • "1to2N" β€” 1,2, 1,2,3,4, 1,2,3,4,5,6 etc β€” runs 1..2N
  • "1to2N+1" β€” 1, 1,2,3, 1,2,3,4,5, etc β€” runs 1..2N+1
  • "1toFib" β€” 1, 1, 1,2, 1,2,3, 1,2,3,4,5 etc β€” runs 1..Fibonacci
  • "Nto0" β€” 0, 1,0, 2,1,0, 3,2,1,0, etc β€” runs N..0
  • "Nto1" β€” 1, 2,1, 3,2,1, 4,3,2,1, etc β€” runs N..1
  • "0toNinc" β€” 0, 1,2, 2,3,4, 3,4,5,6, etc β€” runs 0..N increasing
  • "Nrep" β€” 1, 2,2, 3,3,3, 4,4,4,4, etc β€” N repetitions of N
  • "N+1rep" β€” 0, 1,1, 2,2,2, 3,3,3,3, etc β€” N+1 repetitions of N
  • "2rep" β€” 0,0, 1,1, 2,2, etc β€” two repetitions of each N
  • "3rep" β€” 0,0,0, 1,1,1, 2,2,2, etc β€” three repetitions of N

twelve whole flavours πŸ“ pick your fighter.


the lore on the relationships πŸ”₯

"0toN" and "1toN" differ only the latter being +1. that's IT. one (1) unit. They're related to the triangular numbers (Math::NumSeq::Triangular) in that each run starts at index i=Triangular+1, ie. i=1,2,4,7,11,etc. πŸŽ€

"1to2N" is related to the pronic numbers (Math::NumSeq::Pronic) in that each run starts at index i=Pronic+1, ie. i=1,3,7,13,etc. slay.

"1toFib" not only runs up to each Fibonacci number (Math::NumSeq::Fibonacci), but the runs start at i=Fibonacci too, ie. i=1,2,3,5,8,13,etc. πŸ¦‹ This arises because the cumulative total of Fibonacci numbers has F[1]+F[2]+...+F[k]+1 = F[k+2]. not me doing math at 3am 😭 iconic behaviour honestly.


πŸ’œ FUNCTIONS πŸ’œ

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes. (the shared lore, iykyk)

  • "$seq = Math::NumSeq::Runs->new (runs_type => $str)" β€” Create and return a new sequence object. ✨ your very own sequence, born fresh, no cap.

🎲 Random Access 🎲

  • "$value = $seq->ith($i)" β€” Return the $i'th value from the sequence. just. grab it. whenever. πŸ‘‘
  • "$bool = $seq->pred($value)" β€” Return true if $value occurs in the sequence. This is merely all integer "$value >= 0" or ">= 1" according to the start of the "runs_type". so like, it's not doing anything clever, it's just vibing off the start value πŸ’€

🌈 SEE ALSO 🌈

  • Math::NumSeq
  • Math::NumSeq::AllDigits

🏠 HOME PAGE 🏠

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

go visit. the URL is right there. do it for me 🫢


πŸ“œ LICENSE πŸ“œ

Copyright 2010, 2011, 2012, 2013, 2014, 2015, 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. ⚠️ like fr fr, no promises, read the license.

You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.


this page is User Contributed Perl Documentation, brought to you by perl v5.42.0, dated 2025-07-25, and it lives at Math::NumSeq::Runs(3).

okay that's the whole page bestie, mwah, go run some integers πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from