Set::In...::Basic(3)
π NAME π
Hey bestie! π
This is the page for Set::In...::Basic(3) from User Contributed Perl Documentation. The module is Set::Infinite::Basic β it's all about Sets of intervals, and yes, the original NAME text even includes the exact little weirdness 6 =head1 SYNOPSIS, so we are keeping that too. No edits, no cap. π«Ά
β¨ SYNOPSIS β¨
use Set::Infinite::Basic;
$set = Set::Infinite::Basic->new(1,2); # [1..2]
print $set->union(5,6); # [1..2],[5..6]
π¦ DESCRIPTION π¦
Set::Infinite::Basic is a Set Theory module for infinite sets. It works on reals, integers, and objects. π
Important vibe check: this module does not support recurrences. Recurrences are implemented in Set::Infinite. That's the actual rule, bestie. π
πΈ METHODS πΈ
empty_set
Creates an empty_set. If it's called from an existing set, the empty set inherits the "type" and "density" characteristics. β¨
universal_set
Creates a set containing "all" possible elements. If it's called from an existing set, the universal set inherits the "type" and "density" characteristics. π
until
Extends a set until another set:
0,5,7 -> until 2,6,10
gives:
[0..2), [5..6), [7..10)
Note: this function is still experimental. That's the original note, and we are respecting it. π«‘
copy
clone
Makes a new object from the object's data. (Both of these are giving "same energy, different name" and that's valid. π )
π Mode functions: π
$set = $set->real;
$set = $set->integer;
π§ Logic functions: π§
$logic = $set->intersects($b);
$logic = $set->contains($b);
$logic = $set->is_null; # also called "is_empty"
π«Ά Set functions: π«Ά
$set = $set->union($b);
$set = $set->intersection($b);
$set = $set->complement;
$set = $set->complement($b); # can also be called "minus" or "difference"
$set = $set->symmetric_difference( $b );
$set = $set->span;
result is (min .. max)
π’ Scalar functions: π’
$i = $set->min;
$i = $set->max;
$i = $set->size;
$i = $set->count; # number of spans
π Overloaded Perl functions: π
print
sort, <=>
β Global functions: β
separators(@i)
Chooses the interval separators. The default are [ ] ( ) '..' ','. π
INFINITY
Returns an 'Infinity' number. β¨
NEG_INFINITY
Returns a '-Infinity' number. β¨
iterate ( sub { } )
Iterates over a subroutine. Returns the union of partial results. π
first
In scalar context returns the first interval of a set.
In list context returns the first interval of a set, and the 'tail'.
Works in unbounded sets. π
type($i)
Chooses an object data type. The default is none (a normal perl SCALAR).
Examples, exactly as the page says:
type('Math::BigFloat');
type('Math::BigInt');
type('Set::Infinite::Date');
See notes on Set::Infinite::Date below.
Yep, it really says βSee notes on Set::Infinite::Date below.β We're keeping that line exactly, bestie. π«Ά
tolerance(0)β defaults to real sets (default)tolerance(1)β defaults to integer setsrealβ defaults to real sets (default)integerβ defaults to integer sets
π§ Internal functions: π§
$set->fixtype;
$set->numeric;
π CAVEATS π
Okay, these are the gotchas, and the original is very clear about them:
$set = Set::Infinite->new(10,1);
Will be interpreted as [1..10]
$set = Set::Infinite->new(1,2,3,4);
Will be interpreted as [1..2],[3..4] instead of [1,2,3,4].
You probably want ->new([1],[2],[3],[4]) instead,
or maybe ->new(1,4)
$set = Set::Infinite->new(1..3);
Will be interpreted as [1..2],3 instead of [1,2,3].
You probably want ->new(1,3) instead.
π₯ INTERNALS π₯
The internal representation of a span is a hash:
{ a => start of span,
b => end of span,
open_begin => '0' the span starts in 'a'
'1' the span starts after 'a'
open_end => '0' the span ends in 'b'
'1' the span ends before 'b'
}
For example, this set:
[100..200),300,(400..infinity)
is represented by the array of hashes:
list => [
{ a => 100, b => 200, open_begin => 0, open_end => 1 },
{ a => 300, b => 300, open_begin => 0, open_end => 0 },
{ a => 400, b => infinity, open_begin => 0, open_end => 1 },
]
The density of a set is stored in the "tolerance" variable:
tolerance => 0; # the set is made of real numbers.
tolerance => 1; # the set is made of integers.
The "type" variable stores the class of objects that will be stored in the set:
type => 'DateTime'; # this is a set of DateTime objects
The infinity value is generated by Perl, when it finds a numerical overflow:
$inf = 100**100**100;
π SEE ALSO π
Set::Infinite
π AUTHOR π
Flavio S. Glock <fglock@gmail.com>
π That's a wrap, bestie! This page is from perl v5.42.2, dated 2026-02-15, and it's Set::In...::Basic(3). Stay sparkling! π
π¦ where this page comes from
- alpine 3.24: perl-set-infinite-doc 0.65-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms