« first day (4005 days earlier)      last day (777 days later) » 

13:26
Is there any domestic method in Mathematica for doing set-arithmetic on integer intervals? I mean union, intersection, complement?
14:21
@IstvánZachar Something like IntervalIntersection[Interval[{-2, 3}], Interval[{1, 4}]] ?
 
1 hour later…
15:47
@rhermans Yes, but explicitly for integer intervals, where any interval can be defined as a set of disjoint subintervals.
@rhermans Union should join {-2, 3} and {4, 6} to {-2, 6}, as there is no integer defined between 3 and 4.
16:10
`RegionUnion[
ImplicitRegion[And[-2<=x<=3,x\[Element]Integers], x],
ImplicitRegion[And[4<=x<=6,x\[Element]Integers], x]
]`
Regions can be solved.... Flatten[x/.Solve[x\[Element]%, x]]
16:54
@rhermans Thanks, let me test it.
 
1 hour later…
18:07
@rhermans Unfortunately, I wouldn't call the result convenient, as it lists all valid integers as solutions, instead of a range (or disjoint ranges). I'd then have to use Split or similar to identify consecutive ranges, perhaps even Sort results before. I am not sure this is faster than simply doing Union on the explicit list of integers of the intervals.

« first day (4005 days earlier)      last day (777 days later) »