Number::Tolerant::Union(3pm) | User Contributed Perl Documentation | Number::Tolerant::Union(3pm) |
Number::Tolerant::Union - unions of tolerance ranges
version 1.710
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
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.
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years.
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
my $union = Number::Tolerant::Union->new(@list_of_tolerances);
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.")
This method will return a list of all the acceptable options for the union.
Tolerance unions overload a few operations, mostly comparisons.
A number is less than a union if it is less than all its options.
(a | b | c) & d ==yields==> ((a & d) | (b & d) | (c & d))
Options that have no intersection with the new element are dropped. The intersection of a constant number and a union yields that number, if the number was in the union's ranges and otherwise yields nothing.
Who knows. Collapsing overlapping options, probably.
Ricardo Signes <cpan@semiotic.systems>
This software is copyright (c) 2004 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2023-01-08 | perl v5.36.0 |