Interval playground
Type two intervals in their string form: [a,b], (a,b), [a,b),
(a,b], unbounded (-Infinity,5], or empty ∅. Every operation below runs the real
@xtandard/lib/interval code in your browser. Filled dots are closed (included) ends; hollow dots
are open ends.
| Operation | Call | Result |
|---|---|---|
| Union | a.union(b) | [3,10] |
| Intersection | a.intersection(b) | (4,6) |
| Difference | a.difference(b) | [3,4] ∪ [6,10] |
| Symmetric difference | a.symmetricDifference(b) | [3,4] ∪ [6,10] |
| Span | a.span(b) | [3,10] |
| Gap | a.gap(b) | null |
| Overlaps | a.overlaps(b) | true |
| Connected | a.isConnected(b) | true |
| Adjacent | a.isAdjacent(b) | false |
| A encloses B | a.encloses(b) | true |
| A contains 4 | a.contains(4) | true |
| B contains 4 | b.contains(4) | false |
| Length of A | a.length() | 7 |
| Middle of A | a.middle() | 6.5 |
Click an operation that returns intervals to draw it on the line.
[1,5] ∪ (7,12] ∪ [20,+Infinity)