Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# Set::Infinite 0.61

Date Added: October 14, 2010  |  Visits: 727

Set::Infinite Perl module contains sets of intervals. SYNOPSIS use Set::Infinite; \$set = Set::Infinite->new(1,2); # [1..2] print \$set->union(5,6); # [1..2],[5..6] Set::Infinite is a Set Theory module for infinite sets. A set is a collection of objects. The objects that belong to a set are called its members, or "elements". As objects we allow (almost) anything: reals, integers, and objects (such as dates). We allow sets to be infinite. There is no account for the order of elements. For example, {1,2} = {2,1}. There is no account for repetition of elements. For example, {1,2,2} = {1,1,1,2} = {1,2}. CONSTRUCTOR new Creates a new set object: \$set = Set::Infinite->new; # empty set \$set = Set::Infinite->new( 10 ); # single element \$set = Set::Infinite->new( 10, 20 ); # single range \$set = Set::Infinite->new( [ 10, 20 ], [ 50, 70 ] ); # two ranges empty set \$set = Set::Infinite->new; set with a single element \$set = Set::Infinite->new( 10 ); \$set = Set::Infinite->new( [ 10 ] ); set with a single span \$set = Set::Infinite->new( 10, 20 ); \$set = Set::Infinite->new( [ 10, 20 ] ); # 10 <= x <= 20 set with a single, open span \$set = Set::Infinite->new( { a => 10, open_begin => 0, b => 20, open_end => 1, } ); # 10 <= x < 20 set with multiple spans \$set = Set::Infinite->new( 10, 20, 100, 200 ); \$set = Set::Infinite->new( [ 10, 20 ], [ 100, 200 ] ); \$set = Set::Infinite->new( { a => 10, open_begin => 0, b => 20, open_end => 0, }, { a => 100, open_begin => 0, b => 200, open_end => 0, } ); The new() method expects ordered parameters. If you have unordered ranges, you can build the set using union: @ranges = ( [ 10, 20 ], [ -10, 1 ] ); \$set = Set::Infinite->new; \$set = \$set->union( @\$_ ) for @ranges; The data structures passed to new must be immutable. So this is not good practice: \$set = Set::Infinite->new( \$object_a, \$object_b ); \$object_a->set_value( 10 ); This is the recommended way to do it: \$set = Set::Infinite->new( \$object_a->clone, \$object_b->clone ); \$object_a->set_value( 10 ); clone / copy Creates a new object, and copy the object data. empty_set Creates an empty set. If called from an existing set, the empty set inherits the "type" and "density" characteristics. universal_set Creates a set containing "all" possible elements. If called from an existing set, the universal set inherits the "type" and "density" characteristics..

 Requirements: No special requirements Platforms: Linux Keyword: Empty Set,  Infinite Perl,  Libraries,  New,  Object,  Open,  Perl Module,  Programming,  Setinfinite,  Sets Users rating: 0/10