NAME

Set::Infinite - Perl extension for Sets of intervals

SYNOPSIS

use Set::Infinite;

$a = Set::Infinite->new(1,2);
print $a->union(5,6);

DESCRIPTION

Set::Infinite is a Set Theory module for infinite sets.

It works on strings, reals or integers. You can provide your own objects or let it make them for you using the `type'.

It works very well on dates, providing schedule checks (intersections) and unions.

EXPORT

None by default.

USAGE

$a = Set::Infinite->new();
$a = Set::Infinite->new(1);
$a = Set::Infinite->new(1,2);
$a = Set::Infinite->new($b);
$a = Set::Infinite->new([1], [1,2], [$b]);

Mode functions:

$a->real;

$a->integer;

Logic functions:

$logic = $a->intersects($b);

$logic = $a->contains($b);

$logic = $a->is_null;

Sets functions:

$i = $a->union($b);	

$i = $a->intersection($b);

$i = $a->complement;
$i = $a->complement($b);

$i = $a->span;   

	result is INTERVAL, (min .. max)

$a->add($b);   

	This is a short for:

	$a = $a->union($b);

Scalar functions:

$i = $a->min;

$i = $a->max;

$i = $a->size;  

Perl functions:

@b = sort @a;

print $a;

Global functions:

separators(@i)

	chooses the interval separators. 

	default are [ ] ( ) '..' ','.

null($i)		

	chooses 'null' name. default is 'null'

infinite($i)

	chooses 'infinite' name. default is 'inf'

infinite

	returns an 'infinite' number.

minus_infinite

	returns '-infinite' number.

null

	returns 'null'.

quantize($i)

	returns a tied reference to an array of sets.
	Each array have size $i.
	In some cases, one or more array members may be empty.

	Example: 

		$a = Set::Infinite->new([1,3]);
		print join (" ", $a->quantize(1) );

	Gives: 

		[1..2) [2..3) [3..4)

type($i)

	chooses an object data type. 

	default is none (a normal perl SCALAR).

	examples: 

	type('Math::BigFloat');
	type('Math::BigInt');
	type('Set::Infinite::Date');
		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

Internal functions:

$a->cleanup;

Notes on Set::Infinite::Date

Set::Infinite::Date is a Date "plugin" for sets.

It is invoked by:

type('Set::Infinite::Date');

It requires HTTP:Date and Time::Local

It changes quantize function behaviour to accept time units:

$a = Set::Infinite->new('2001-05-02', '2001-05-13');
print "Weeks in $a: ", join (" ", $a->quantize('weeks', 1) );

$a = Set::Infinite->new('09:30', '10:35');
print "Quarters of hour in $a: ", join (" ", $a->quantize('minutes', 15) );

Units can be years, months, days, weeks, hours, minutes, or seconds.

max and min functions will show in date/time format, unless they are used with `0 + '.

CAVEATS

$a = Set::Infinite->new(10,1);
	Will be interpreted as [1..10]

$a = 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) 

$a = Set::Infinite->new(1..3);
	Will be interpreted as [1..2],3 instead of [1,2,3].
	You probably want ->new(1,3) instead.

AUTHOR

Flavio Soibelmann Glock <fglock@pucrs.br>