Kevin Ryde >
Math-NumSeq >
Math::NumSeq::Base::IteratePred

Module Version: 72
Math::NumSeq::Base::IteratePred -- iterate by searching with pred()

package MyNumSeqSubclass; use Math::NumSeq; use Math::NumSeq::Base::IteratePred; @ISA = ('Math::NumSeq::Base::IteratePred', 'Math::NumSeq'); sub ith { my ($self, $i) = @_; return something($i); }

This is a multi-inheritance mix-in providing the following methods

rewind() # return to $self->i_start() and $self->values_min() next() # search using $self->pred() characteristic_increasing() # always true characteristic_integer() # always true

`next()`

iterates by searching for values satisfying `$self->pred($value)`

, starting at `values_min()`

and stepping by 1 each time.

This is a handy way to implement the iterating methods for a `NumSeq`

if there's no easy way to step or have random access to values, only a test of a condition.

The current implementation is designed for infinite sequences, it doesn't check for a `values_max()`

limit.

The two "characteristic" methods mean that calls

$self->characteristic('increasing') $self->characteristic('integer')

are both true. "Increasing" is since `next()`

always searches upwards. "Integer" currently presumes that the starting `values_min()`

is an integer.

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

Copyright 2011, 2012, 2013, 2014 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/>.

syntax highlighting: