Set::Infinite::_recurrence(3pm)

Set::Infinite::_recurrence3pm

Extends set::infinite with recurrence functions

Usage

    $recurrence = $base_set->_recurrence ( \&next, \&previous );

Overview

This is an internal class used by the DateTime::Set module. The API is subject to change.

It provides all functionality provided by Set::Infinite, plus the ability to define recurrences with arbitrary objects, such as dates.

Methods

•

_recurrence ( \&next, \&previous )

Creates a recurrence set. The set is defined inside a 'base set'.

   $recurrence = $base_set->_recurrence ( \&next, \&previous );

The recurrence functions take one argument, and return the 'next' or the 'previous' occurrence.

Example: defines the set of all 'integer numbers':

    use strict;
    use Set::Infinite::_recurrence;
    use POSIX qw(floor);
    # define the recurrence span
    my $forever = Set::Infinite::_recurrence->new( 
        Set::Infinite::_recurrence::NEG_INFINITY, 
        Set::Infinite::_recurrence::INFINITY
    );
    my $recurrence = $forever->_recurrence(
        sub {   # next
                floor( $_[0] + 1 ) 
            },   
        sub {   # previous
                my $tmp = floor( $_[0] ); 
                $tmp < $_[0] ? $tmp : $_[0] - 1
            },   
    );
    print "sample recurrence ",
          $recurrence->intersection( -5, 5 ), "\n";
    # sample recurrence -5,-4,-3,-2,-1,0,1,2,3,4,5
    {
        my $x = 234.567;
        print "next occurrence after $x = ",
              $recurrence->{param}[0]->( $x ), "\n";  # 235
        print "previous occurrence before $x = ",
              $recurrence->{param}[2]->( $x ), "\n";  # 234
    }
    {
        my $x = 234;
        print "next occurrence after $x = ",
              $recurrence->{param}[0]->( $x ), "\n";  # 235
        print "previous occurrence before $x = ",
              $recurrence->{param}[2]->( $x ), "\n";  # 233
    }
•

is_forever

Returns true if the set is a single span, ranging from -Infinity to Infinity.

•

_is_recurrence

Returns true if the set is an unbounded recurrence, ranging from -Infinity to Infinity.

Constants

•

INFINITY

The "Infinity" value.

•

NEG_INFINITY

The "-Infinity" value.

Support

Support is offered through the "[email protected]" mailing list.

Please report bugs using rt.cpan.org

Releases

10 releases since Debian 5.0 (Lenny); the text changed 7 times.

  1. 5.0
  2. 6.0
  3. 7
  4. 8
  5. 9–10
  6. 11
  7. 12–13
  8. Arch

Author

Flavio Soibelmann Glock <[email protected]>

The recurrence generation algorithm is based on an idea from Dave Rolsky.

From perl-datetime-set 0.3900-5 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.