1Set::Infinite::_recurreUnsceer(3C)ontributed Perl DocumeSnetta:t:iIonnfinite::_recurrence(3)
2
3
4

NAME

6       Set::Infinite::_recurrence - Extends Set::Infinite with recurrence
7       functions
8

SYNOPSIS

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

DESCRIPTION

13       This is an internal class used by the DateTime::Set module.  The API is
14       subject to change.
15
16       It provides all functionality provided by Set::Infinite, plus the
17       ability to define recurrences with arbitrary objects, such as dates.
18

METHODS

20       ·   _recurrence ( \&next, \&previous )
21
22           Creates a recurrence set. The set is defined inside a 'base set'.
23
24              $recurrence = $base_set->_recurrence ( \&next, \&previous );
25
26           The recurrence functions take one argument, and return the 'next'
27           or the 'previous' occurence.
28
29           Example: defines the set of all 'integer numbers':
30
31               use strict;
32
33               use Set::Infinite::_recurrence;
34               use POSIX qw(floor);
35
36               # define the recurrence span
37               my $forever = Set::Infinite::_recurrence->new(
38                   Set::Infinite::_recurrence::NEG_INFINITY,
39                   Set::Infinite::_recurrence::INFINITY
40               );
41
42               my $recurrence = $forever->_recurrence(
43                   sub {   # next
44                           floor( $_[0] + 1 )
45                       },
46                   sub {   # previous
47                           my $tmp = floor( $_[0] );
48                           $tmp < $_[0] ? $tmp : $_[0] - 1
49                       },
50               );
51
52               print "sample recurrence ",
53                     $recurrence->intersection( -5, 5 ), "\n";
54               # sample recurrence -5,-4,-3,-2,-1,0,1,2,3,4,5
55
56               {
57                   my $x = 234.567;
58                   print "next occurence after $x = ",
59                         $recurrence->{param}[0]->( $x ), "\n";  # 235
60                   print "previous occurence before $x = ",
61                         $recurrence->{param}[2]->( $x ), "\n";  # 234
62               }
63
64               {
65                   my $x = 234;
66                   print "next occurence after $x = ",
67                         $recurrence->{param}[0]->( $x ), "\n";  # 235
68                   print "previous occurence before $x = ",
69                         $recurrence->{param}[2]->( $x ), "\n";  # 233
70               }
71
72       ·   is_forever
73
74           Returns true if the set is a single span, ranging from -Infinity to
75           Infinity.
76
77       ·   _is_recurrence
78
79           Returns true if the set is an unbounded recurrence, ranging from
80           -Infinity to Infinity.
81

CONSTANTS

83       ·   INFINITY
84
85           The "Infinity" value.
86
87       ·   NEG_INFINITY
88
89           The "-Infinity" value.
90

SUPPORT

92       Support is offered through the "datetime@perl.org" mailing list.
93
94       Please report bugs using rt.cpan.org
95

AUTHOR

97       Flavio Soibelmann Glock <fglock@pucrs.br>
98
99       The recurrence generation algorithm is based on an idea from Dave
100       Rolsky.
101
103       Copyright (c) 2003 Flavio Soibelmann Glock. All rights reserved.  This
104       program is free software; you can distribute it and/or modify it under
105       the same terms as Perl itself.
106
107       The full text of the license can be found in the LICENSE file included
108       with this module.
109

SEE ALSO

111       Set::Infinite
112
113       DateTime::Set
114
115       For details on the Perl DateTime Suite project please see
116       <http://datetime.perl.org>.
117
118
119
120perl v5.12.0                      2010-05-14     Set::Infinite::_recurrence(3)
Impressum