search.cpan.org is shutting down
Kevin Ryde > Math-NumSeq > Math::NumSeq::Runs

Math-NumSeq-72.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 0
View/Report Bugs
Module Version: 72

# NAME

Math::NumSeq::Runs -- runs of consecutive integers

# SYNOPSIS

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

# DESCRIPTION

This is various kinds of runs of integers. The `runs_type` parameter (a string) can be

```    "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```

"0toN" and "1toN" differ only the latter being +1. 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.

"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].

# FUNCTIONS

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

`\$seq = Math::NumSeq::Runs->new (runs_type => \$str)`

Create and return a new sequence object.

## Random Access

`\$value = \$seq->ith(\$i)`

Return the `\$i`'th value from the sequence.

`\$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`.

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