Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: union and intersection of ranges

by BillKSmith (Monsignor)
on Feb 09, 2023 at 17:07 UTC ( [id://11150275] : note . print w/replies, xml ) Need Help??


in reply to Re: union and intersection of ranges
in thread union and intersection of ranges

If you assume that 'ranges' are 'sets', the terms 'union' and 'intersection' are well defined. They are both sets. Marshall has given shown how to compute them directly from the definitions. Perhaps your spec intends for you to compare the cardinality of these sets.

If you assume that 'ranges' are ordered lists, you need LanX's assumptions to make any sense at all. (The calculation is much simpler because it exploits the ordering.)

Fortunately, both sets of assumptions produce the same results.

Bill