interval-operations {reservr}R Documentation

Convex union and intersection of intervals

Description

Convex union and intersection of intervals

Usage

interval_union(..., intervals = list())

interval_intersection(..., intervals = list())

Arguments

...

appened to intervals if present.

intervals

A list of Intervals.

Value

interval_union returns the convex union of all intervals in intervals. This is the smallest interval completely containing all intervals.

interval_intersection returns the set intersection of all intervals in intervals. The empty set is represented by the open interval (0, 0).

See Also

interval

Examples

interval_union(
  interval(c(0, 1), closed = TRUE),
  interval(c(1, 2))
)

interval_union(
  interval(c(0, 5)),
  interval(c(1, 4), closed = TRUE)
)

# Convex union is not equal to set union:
interval_union(
  interval(c(0, 1)),
  interval(c(2, 3))
)

# The empty union is {}
interval_union()

interval_intersection(
  interval(c(0, 1)),
  interval(c(0.5, 2))
)

interval_intersection(
  interval(c(0, Inf)),
  interval(c(-Inf, 0))
)

interval_intersection(
  interval(c(0, Inf), include_lowest = TRUE),
  interval(c(-Inf, 0), include_highest = TRUE)
)

interval_intersection(
  interval(c(0, 5)),
  interval(c(1, 6), closed = TRUE)
)

# The empty intersection is (-Inf, Inf)
interval_intersection()

[Package reservr version 0.0.3 Index]