1Set::Infinite::Basic(3)User Contributed Perl DocumentatioSnet::Infinite::Basic(3)
2
3
4

NAME

6       Set::Infinite::Basic - Sets of intervals 6 =head1 SYNOPSIS
7
8         use Set::Infinite::Basic;
9
10         $set = Set::Infinite::Basic->new(1,2);    # [1..2]
11         print $set->union(5,6);            # [1..2],[5..6]
12

DESCRIPTION

14       Set::Infinite::Basic is a Set Theory module for infinite sets.
15
16       It works on reals, integers, and objects.
17
18       This module does not support recurrences. Recurrences are implemented
19       in Set::Infinite.
20

METHODS

22   empty_set
23       Creates an empty_set.
24
25       If called from an existing set, the empty set inherits the "type" and
26       "density" characteristics.
27
28   universal_set
29       Creates a set containing "all" possible elements.
30
31       If called from an existing set, the universal set inherits the "type"
32       and "density" characteristics.
33
34   until
35       Extends a set until another:
36
37           0,5,7 -> until 2,6,10
38
39       gives
40
41           [0..2), [5..6), [7..10)
42
43       Note: this function is still experimental.
44
45   copy
46   clone
47       Makes a new object from the object's data.
48
49   Mode functions:
50           $set = $set->real;
51
52           $set = $set->integer;
53
54   Logic functions:
55           $logic = $set->intersects($b);
56
57           $logic = $set->contains($b);
58
59           $logic = $set->is_null;  # also called "is_empty"
60
61   Set functions:
62           $set = $set->union($b);
63
64           $set = $set->intersection($b);
65
66           $set = $set->complement;
67           $set = $set->complement($b);   # can also be called "minus" or "difference"
68
69           $set = $set->symmetric_difference( $b );
70
71           $set = $set->span;
72
73               result is (min .. max)
74
75   Scalar functions:
76           $i = $set->min;
77
78           $i = $set->max;
79
80           $i = $set->size;
81
82           $i = $set->count;  # number of spans
83
84   Overloaded Perl functions:
85           print
86
87           sort, <=>
88
89   Global functions:
90           separators(@i)
91
92               chooses the interval separators.
93
94               default are [ ] ( ) '..' ','.
95
96           INFINITY
97
98               returns an 'Infinity' number.
99
100           NEG_INFINITY
101
102               returns a '-Infinity' number.
103
104           iterate ( sub { } )
105
106               Iterates over a subroutine.
107               Returns the union of partial results.
108
109           first
110
111               In scalar context returns the first interval of a set.
112
113               In list context returns the first interval of a set, and the
114               'tail'.
115
116               Works in unbounded sets
117
118           type($i)
119
120               chooses an object data type.
121
122               default is none (a normal perl SCALAR).
123
124               examples:
125
126               type('Math::BigFloat');
127               type('Math::BigInt');
128               type('Set::Infinite::Date');
129                   See notes on Set::Infinite::Date below.
130
131           tolerance(0)    defaults to real sets (default)
132           tolerance(1)    defaults to integer sets
133
134           real            defaults to real sets (default)
135
136           integer         defaults to integer sets
137
138   Internal functions:
139           $set->fixtype;
140
141           $set->numeric;
142

CAVEATS

144           $set = Set::Infinite->new(10,1);
145               Will be interpreted as [1..10]
146
147           $set = Set::Infinite->new(1,2,3,4);
148               Will be interpreted as [1..2],[3..4] instead of [1,2,3,4].
149               You probably want ->new([1],[2],[3],[4]) instead,
150               or maybe ->new(1,4)
151
152           $set = Set::Infinite->new(1..3);
153               Will be interpreted as [1..2],3 instead of [1,2,3].
154               You probably want ->new(1,3) instead.
155

INTERNALS

157       The internal representation of a span is a hash:
158
159           { a =>   start of span,
160             b =>   end of span,
161             open_begin =>   '0' the span starts in 'a'
162                             '1' the span starts after 'a'
163             open_end =>     '0' the span ends in 'b'
164                             '1' the span ends before 'b'
165           }
166
167       For example, this set:
168
169           [100..200),300,(400..infinity)
170
171       is represented by the array of hashes:
172
173           list => [
174               { a => 100, b => 200, open_begin => 0, open_end => 1 },
175               { a => 300, b => 300, open_begin => 0, open_end => 0 },
176               { a => 400, b => infinity, open_begin => 0, open_end => 1 },
177           ]
178
179       The density of a set is stored in the "tolerance" variable:
180
181           tolerance => 0;  # the set is made of real numbers.
182
183           tolerance => 1;  # the set is made of integers.
184
185       The "type" variable stores the class of objects that will be stored in
186       the set.
187
188           type => 'DateTime';   # this is a set of DateTime objects
189
190       The infinity value is generated by Perl, when it finds a numerical
191       overflow:
192
193           $inf = 100**100**100;
194

SEE ALSO

196           Set::Infinite
197

AUTHOR

199           Flavio S. Glock <fglock@gmail.com>
200
201
202
203perl v5.36.0                      2022-07-22           Set::Infinite::Basic(3)
Impressum