to cut a long story short, I made the Math::Interval module to extend the Range class to provide a working Interval Arithmetic model that uses a Junctions of Ranges to represent disjoint results
# a divisor that spans 0 produces a disjoint multi-interval
my $j1 = (2..4)/(-2..4);
ddt $j1; #any(-Inf..-1.0, 0.5..Inf).Junction
say 3 ~~ $j1; #True
you may be interested in the relationship between programmatic Junctions and Interval Arithmetic ...
a question in our Discord channel asked "why are arithmetic operations on Ranges restricted" with some examples like this:
to cut a long story short, I made the Math::Interval module to extend the Range class to provide a working Interval Arithmetic model that uses a Junctions of Ranges to represent disjoint results (The long story is at https://rakujourney.wordpress.com/2023/11/11/junctions-for-i...)