Learn R Programming

set6 (version 0.1.1)

Interval: Mathematical Finite or Infinite Interval

Description

A general Interval object for mathematical intervals, inheriting from Set. Intervals may be open, closed, or half-open; as well as bounded above, below, or not at all.

Value

R6 object of class Interval inheriting from Set.

Constructor

Interval$new(lower = -Inf, upper = Inf, type = c("[]","(]","[)","()"), class = "numeric", universe = Reals$new())

Constructor Arguments

Argument Type Details
lower numeric Lower limit of the interval.
upper numeric Upper limit of the interval.
type character One of: '()', '(]', '[)', '[]', which specifies if interval is open, left-open, right-open, or closed.
class character One of: 'numeric', 'integer', which specifies if interval is over the Reals or Integers.

Constructor Details

If defaults are used then the Real number line is constructed. The universe argument is useful for taking the complement of the Set. If a universe isn't given then Reals is assumed.

Public Fields

Field Link

class class elements elements length length lower lower upper upper max max min min range range properties properties traits traits type type

Public Methods

Interval Methods Link
isSubinterval(x, proper = FALSE, all = FALSE) isSubinterval

Comparison Methods Link contains(x, all = FALSE, bound = NULL) contains equals(x, all = FALSE) equals isSubset(x, proper = FALSE, all = FALSE) isSubset Representation Methods Link strprint(n = 2) strprint print(n = 2) print summary(n = 2) summary

Details

The Interval class can be used for finite or infinite intervals, but often Sets will be preferred for integer intervals over a finite continuous range. Use Complex to define an interval with complex values.

See Also

Other sets: ConditionalSet, FuzzySet, FuzzyTuple, Set, Tuple, UniversalSet

Examples

Run this code
# NOT RUN {
# Set of Reals
Interval$new()

# Set of Integers
Interval$new(class = "integer")

# Half-open interval
i = Interval$new(1, 10, "(]")
i$contains(c(1, 10))
i$contains(c(1, 10), bound = TRUE)

# Equivalent Set and Interval
Set$new(1:5) == Interval$new(1,5,class="integer")

# SpecialSets can provide more efficient implementation
Interval$new() == ExtendedReals$new()
Interval$new(class = "integer", type = "()") == Integers$new()

# }

Run the code above in your browser using DataLab