Learn R Programming

set6 (version 0.1.0)

Tuple: Mathematical Tuple

Description

A general Tuple object for mathematical tuples, inheriting from Set.

Value

R6 object of class Tuple inheriting from Set.

Constructor

Tuple$new(..., universe = NULL)

Constructor Arguments

Argument Type Details
... ANY Elements in the tuple.

Constructor Details

Tuples are constructed by elements of any types (including R6 classes). The optional universe argument is useful for taking the absolute complement of the Tuple. 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

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

Details

Tuples are similar to sets, except that they drop the constraint for elements to be unique, and ordering in a tuple does matter. Tuples are useful for methods including contains that may require non-unique elements. They are also the return type of the product of sets. See examples.

See Also

Other sets: ConditionalSet, FuzzySet, FuzzyTuple, Interval, Set

Examples

Run this code
# NOT RUN {
# Tuple of integers
Tuple$new(1:5)

# Tuple of multiple types
Tuple$new("a", 5, Set$new(1), Tuple$new(2))

# Each Tuple has properties and traits
t = Tuple$new(1,2,3)
t$traits
t$properties

# Elements can be duplicated
Tuple$new(2, 2) != Tuple$new(2)

# Ordering does matter
Tuple$new(1, 2) != Tuple$new(2, 1)

# }

Run the code above in your browser using DataLab