.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Set::Infinite::Basic 3" .TH Set::Infinite::Basic 3 2024-07-13 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Set::Infinite::Basic \- Sets of intervals 6 =head1 SYNOPSIS .PP .Vb 1 \& use Set::Infinite::Basic; \& \& $set = Set::Infinite::Basic\->new(1,2); # [1..2] \& print $set\->union(5,6); # [1..2],[5..6] .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Set::Infinite::Basic is a Set Theory module for infinite sets. .PP It works on reals, integers, and objects. .PP This module does not support recurrences. Recurrences are implemented in Set::Infinite. .SH METHODS .IX Header "METHODS" .SS empty_set .IX Subsection "empty_set" Creates an empty_set. .PP If called from an existing set, the empty set inherits the "type" and "density" characteristics. .SS universal_set .IX Subsection "universal_set" Creates a set containing "all" possible elements. .PP If called from an existing set, the universal set inherits the "type" and "density" characteristics. .SS until .IX Subsection "until" Extends a set until another: .PP .Vb 1 \& 0,5,7 \-> until 2,6,10 .Ve .PP gives .PP .Vb 1 \& [0..2), [5..6), [7..10) .Ve .PP Note: this function is still experimental. .SS copy .IX Subsection "copy" .SS clone .IX Subsection "clone" Makes a new object from the object's data. .SS "Mode functions:" .IX Subsection "Mode functions:" .Vb 1 \& $set = $set\->real; \& \& $set = $set\->integer; .Ve .SS "Logic functions:" .IX Subsection "Logic functions:" .Vb 1 \& $logic = $set\->intersects($b); \& \& $logic = $set\->contains($b); \& \& $logic = $set\->is_null; # also called "is_empty" .Ve .SS "Set functions:" .IX Subsection "Set functions:" .Vb 1 \& $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) .Ve .SS "Scalar functions:" .IX Subsection "Scalar functions:" .Vb 1 \& $i = $set\->min; \& \& $i = $set\->max; \& \& $i = $set\->size; \& \& $i = $set\->count; # number of spans .Ve .SS "Overloaded Perl functions:" .IX Subsection "Overloaded Perl functions:" .Vb 1 \& print \& \& sort, <=> .Ve .SS "Global functions:" .IX Subsection "Global functions:" .Vb 1 \& separators(@i) \& \& chooses the interval separators. \& \& default are [ ] ( ) \*(Aq..\*(Aq \*(Aq,\*(Aq. \& \& INFINITY \& \& returns an \*(AqInfinity\*(Aq number. \& \& NEG_INFINITY \& \& returns a \*(Aq\-Infinity\*(Aq 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 \& \*(Aqtail\*(Aq. \& \& Works in unbounded sets \& \& type($i) \& \& chooses an object data type. \& \& default is none (a normal perl SCALAR). \& \& examples: \& \& type(\*(AqMath::BigFloat\*(Aq); \& type(\*(AqMath::BigInt\*(Aq); \& type(\*(AqSet::Infinite::Date\*(Aq); \& See notes on Set::Infinite::Date below. \& \& tolerance(0) defaults to real sets (default) \& tolerance(1) defaults to integer sets \& \& real defaults to real sets (default) \& \& integer defaults to integer sets .Ve .SS "Internal functions:" .IX Subsection "Internal functions:" .Vb 1 \& $set\->fixtype; \& \& $set\->numeric; .Ve .SH CAVEATS .IX Header "CAVEATS" .Vb 2 \& $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. .Ve .SH INTERNALS .IX Header "INTERNALS" The internal representation of a \fIspan\fR is a hash: .PP .Vb 7 \& { a => start of span, \& b => end of span, \& open_begin => \*(Aq0\*(Aq the span starts in \*(Aqa\*(Aq \& \*(Aq1\*(Aq the span starts after \*(Aqa\*(Aq \& open_end => \*(Aq0\*(Aq the span ends in \*(Aqb\*(Aq \& \*(Aq1\*(Aq the span ends before \*(Aqb\*(Aq \& } .Ve .PP For example, this set: .PP .Vb 1 \& [100..200),300,(400..infinity) .Ve .PP is represented by the array of hashes: .PP .Vb 5 \& 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 }, \& ] .Ve .PP The \fIdensity\fR of a set is stored in the \f(CW\*(C`tolerance\*(C'\fR variable: .PP .Vb 1 \& tolerance => 0; # the set is made of real numbers. \& \& tolerance => 1; # the set is made of integers. .Ve .PP The \f(CW\*(C`type\*(C'\fR variable stores the \fIclass\fR of objects that will be stored in the set. .PP .Vb 1 \& type => \*(AqDateTime\*(Aq; # this is a set of DateTime objects .Ve .PP The \fIinfinity\fR value is generated by Perl, when it finds a numerical overflow: .PP .Vb 1 \& $inf = 100**100**100; .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" .Vb 1 \& Set::Infinite .Ve .SH AUTHOR .IX Header "AUTHOR" .Vb 1 \& Flavio S. Glock .Ve