Skip to content

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.

34610AB=
OperationCallResult
Uniona.union(b)[3,10]
Intersectiona.intersection(b)(4,6)
Differencea.difference(b)[3,4] ∪ [6,10]
Symmetric differencea.symmetricDifference(b)[3,4] ∪ [6,10]
Spana.span(b)[3,10]
Gapa.gap(b)null
Overlapsa.overlaps(b)true
Connecteda.isConnected(b)true
Adjacenta.isAdjacent(b)false
A encloses Ba.encloses(b)true
A contains 4a.contains(4)true
B contains 4b.contains(4)false
Length of Aa.length()7
Middle of Aa.middle()6.5

Click an operation that returns intervals to draw it on the line.

[1,5] ∪ (7,12] ∪ [20,+Infinity)