r-k-b/elm-interval/2.0.0

NOTE: this package is not compatible with Elm 0.19.1

Union

A set of strictly ordered, fully disjoint Intervals.

Types

type Union

A set of strictly non-overlapping Intervals.

Opaque type; do not export.

fromInterval : Interval -> Union

Construct a "union" from a single Interval.

fromIntervals : List Interval -> Union

Additively construct a union from an unordered list of arbitrary Intervals.

union : Union -> Union -> Union

Merge two Unions. E.g.:

  • { [1, 2) } ∪ { [3, 4] } = { [1, 2), [3, 4] }
  • { [1, 2) } ∪ { [2, 3] } = { [1, 3] }
  • { [1, 2) } ∪ { (2, 3] } = { [1, 2), (2, 3] }
unionOfIntervals : Interval -> Interval -> Union

Construct a Union from the additive merger of two Intervals. E.g.:

  • [1, 2) ∪ [3, 4] = { [1, 2), [3, 4] }
intersection : Union -> Union -> Union

Return the intersection of two Unions. E.g.:

  • { [1, 2) } ∩ { [3, 5] } = {}
  • { [1, 3) } ∩ { [2, 5] } = { [2, 3) }
  • { [1, 3), [4, 6] } ∩ { [2, 5] } = { [2, 3), [4, 5] }
intersectionWithInterval : Interval -> Union -> Union

Return the intersection of an interval with a Union. E.g.:

  • [1, 2) ∩ { [3, 5] } = {}
  • [1, 3) ∩ { [2, 5] } = { [2, 3) }
  • [2, 5] ∩ { [1, 3), [4, 6] } = { [2, 3), [4, 5] }
subtract : Interval -> Interval -> Union

Subtract interval b from interval a, returning the parts of a that did not intersect with b.

E.g.:

  • [1, 3) - (1, 2] = { {1}, (2, 3) }
subtractInterval : Interval -> Union -> Union

Subtract an interval from the given union, returning the contents of the union that did not intersect with the interval.

E.g.:

  • { [1, 3), (5, 8] } - (1, 3) = { {1}, (5, 8] }
subtractUnions : Union -> Union -> Union

Subtract union b from union a, returning the contents of a that did not intersect with b.

E.g.:

  • { [1, 3), (5, 8] } - { (1, 3), [6, 7] } = { {1}, (5, 6), (7, 8] }
unionToString : Union -> String

Return the string representation of the given Union.