The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Number::Tolerant::Union -- unions of tolerance ranges

SYNOPSIS

 use Number::Tolerant;

 my $range1 = tolerance(10 => to => 12);
 my $range2 = tolerance(14 => to => 16);

 my $union = $range1 | $range2;

 if ($11 == $union) { ... } # this will happen
 if ($12 == $union) { ... } # so will this
 
 if ($13 == $union) { ... } # nothing will happen here

 if ($14 == $union) { ... } # this will happen
 if ($15 == $union) { ... } # so will this

DESCRIPTION

Number::Tolerant::Union is used by Number::Tolerant to represent the union of multiple tolerances. A subset of the same operators that function on a tolerance will function on a union of tolerances, as listed below.

METHODS

Instantiation

There is a new method on the Number::Tolerant::Union class, but unions are meant to be created with the | operator on a Number::Tolerant tolerance.

The arguments to new are a list of numbers or tolerances to be unioned.

Intersecting ranges are not converted into a single range, but this may change in the future. (For example, the union of "5 to 10" and "7 to 12" is not "5 to 12.")

Overloading

Tolerance unions overload a few operations, mostly comparisons.

numification

Unions numify to undef. If there's a better idea, I'd love to hear it.

stringification

A tolerance stringifies to a short description of itself. This is a set of the union's options, parentheses-enclosed and joined by the word "or"

equality

A number is equal to a union if it is equal to any of its options.

comparison

A number is greater than a union if it is greater than all its options.

A number is less than a union if it is less than all its options.

union intersection

There is no & operator overloading for unions... yet.

TODO

Who knows. Intersection commution, probably.

AUTHOR

Ricardo SIGNES, <rjbs@cpan.org>

COPYRIGHT

(C) 2004, Ricardo SIGNES. Number::Tolerant::Union is available under the same terms as Perl itself.