GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Set::Infinite::_recurrence(3) User Contributed Perl Documentation Set::Infinite::_recurrence(3)

Set::Infinite::_recurrence - Extends Set::Infinite with recurrence functions

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

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.

  • _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.

  • INFINITY

    The "Infinity" value.

  • NEG_INFINITY

    The "-Infinity" value.

Support is offered through the "datetime@perl.org" mailing list.

Please report bugs using rt.cpan.org

Flavio Soibelmann Glock <fglock@gmail.com>

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

Copyright (c) 2003 Flavio Soibelmann Glock. All rights reserved. This program is free software; you can distribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

Set::Infinite

DateTime::Set

For details on the Perl DateTime Suite project please see <http://datetime.perl.org>.

2016-10-09 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.