1Math::NumSeq::Runs(3) User Contributed Perl DocumentationMath::NumSeq::Runs(3)
2
3
4
6 Math::NumSeq::Runs -- runs of consecutive integers
7
9 use Math::NumSeq::Runs;
10 my $seq = Math::NumSeq::Runs->new;
11 my ($i, $value) = $seq->next;
12
14 This is various kinds of runs of integers. The "runs_type" parameter
15 (a string) can be
16
17 "0toN" 0, 0,1, 0,1,2, 0,1,2,3, etc runs 0..N
18 "1toN" 1, 1,2, 1,2,3, 1,2,3,4, etc runs 1..N
19 "1to2N" 1,2, 1,2,3,4, 1,2,3,4,5,6 etc runs 1..2N
20 "1to2N+1" 1, 1,2,3, 1,2,3,4,5, etc runs 1..2N+1
21 "1toFib" 1, 1, 1,2, 1,2,3, 1,2,3,4,5 etc runs 1..Fibonacci
22 "Nto0" 0, 1,0, 2,1,0, 3,2,1,0, etc runs N..0
23 "Nto1" 1, 2,1, 3,2,1, 4,3,2,1, etc runs N..1
24 "0toNinc" 0, 1,2, 2,3,4, 3,4,5,6, etc runs 0..N increasing
25 "Nrep" 1, 2,2, 3,3,3, 4,4,4,4, etc N repetitions of N
26 "N+1rep" 0, 1,1, 2,2,2, 3,3,3,3, etc N+1 repetitions of N
27 "2rep" 0,0, 1,1, 2,2, etc two repetitions of each N
28 "3rep" 0,0,0, 1,1,1, 2,2,2, etc three repetitions of N
29
30 "0toN" and "1toN" differ only the latter being +1. They're related to
31 the triangular numbers (Math::NumSeq::Triangular) in that each run
32 starts at index i=Triangular+1, ie. i=1,2,4,7,11,etc.
33
34 "1to2N" is related to the pronic numbers (Math::NumSeq::Pronic) in that
35 each run starts at index i=Pronic+1, ie. i=1,3,7,13,etc.
36
37 "1toFib" not only runs up to each Fibonacci number
38 (Math::NumSeq::Fibonacci), but the runs start at i=Fibonacci too, ie.
39 i=1,2,3,5,8,13,etc. This arises because the cumulative total of
40 Fibonacci numbers has F[1]+F[2]+...+F[k]+1 = F[k+2].
41
43 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
44 classes.
45
46 "$seq = Math::NumSeq::Runs->new (runs_type => $str)"
47 Create and return a new sequence object.
48
49 Random Access
50 "$value = $seq->ith($i)"
51 Return the $i'th value from the sequence.
52
53 "$bool = $seq->pred($value)"
54 Return true if $value occurs in the sequence. This is merely all
55 integer "$value >= 0" or ">= 1" according to the start of the
56 "runs_type".
57
59 Math::NumSeq, Math::NumSeq::AllDigits
60
62 <http://user42.tuxfamily.org/math-numseq/index.html>
63
65 Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2019 Kevin Ryde
66
67 Math-NumSeq is free software; you can redistribute it and/or modify it
68 under the terms of the GNU General Public License as published by the
69 Free Software Foundation; either version 3, or (at your option) any
70 later version.
71
72 Math-NumSeq is distributed in the hope that it will be useful, but
73 WITHOUT ANY WARRANTY; without even the implied warranty of
74 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
75 General Public License for more details.
76
77 You should have received a copy of the GNU General Public License along
78 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
79
80
81
82perl v5.32.0 2020-07-28 Math::NumSeq::Runs(3)