Description Details Super class Methods See Also Examples
A general Tuple object for mathematical tuples, inheriting from Set
.
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.
set6::Set
-> Tuple
equals()
Tests if two sets are equal.
Tuple$equals(x, all = FALSE)
x
Set or vector of Sets.
all
logical. If FALSE
tests each x
separately. Otherwise returns TRUE
only if all x
pass test.
An object is equal to a Tuple if it contains all the same elements, and in the same order. Infix operators can be used for:
Equal | == |
Not equal | != |
If all
is TRUE
then returns TRUE
if all x
are equal to the Set, otherwise
FALSE
. If all
is FALSE
then returns a vector of logicals corresponding to each individual
element of x
.
Tuple$new(1,2) == Tuple$new(1,2) Tuple$new(1,2) != Tuple$new(1,2) Tuple$new(1,1) != Set$new(1,1)
isSubset()
Test if one set is a (proper) subset of another
Tuple$isSubset(x, proper = FALSE, all = FALSE)
x
any. Object or vector of objects to test.
proper
logical. If TRUE
tests for proper subsets.
all
logical. If FALSE
tests each x
separately. Otherwise returns TRUE
only if all x
pass test.
If using the method directly, and not via one of the operators then the additional boolean
argument proper
can be used to specify testing of subsets or proper subsets. A Set is a proper
subset of another if it is fully contained by the other Set (i.e. not equal to) whereas a Set is a
(non-proper) subset if it is fully contained by, or equal to, the other Set.
When calling $isSubset
on objects inheriting from Interval, the method treats the interval as if
it is a Set, i.e. ordering and class are ignored. Use $isSubinterval
to test if one interval
is a subinterval of another.
Infix operators can be used for:
Subset | < |
Proper Subset | <= |
Superset | > |
Proper Superset | >=
|
An object is a (proper) subset of a Tuple if it contains all (some) of the same elements, and in the same order.
If all
is TRUE
then returns TRUE
if all x
are subsets of the Set, otherwise
FALSE
. If all
is FALSE
then returns a vector of logicals corresponding to each individual
element of x
.
Tuple$new(1,2,3) < Tuple$new(1,2,3,4) Tuple$new(1,3,2) < Tuple$new(1,2,3,4)
clone()
The objects of this class are cloneable with this method.
Tuple$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other sets:
ConditionalSet
,
FuzzyMultiset
,
FuzzySet
,
FuzzyTuple
,
Interval
,
Multiset
,
Set
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # 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)
## ------------------------------------------------
## Method `Tuple$equals`
## ------------------------------------------------
Tuple$new(1,2) == Tuple$new(1,2)
Tuple$new(1,2) != Tuple$new(1,2)
Tuple$new(1,1) != Set$new(1,1)
## ------------------------------------------------
## Method `Tuple$isSubset`
## ------------------------------------------------
Tuple$new(1,2,3) < Tuple$new(1,2,3,4)
Tuple$new(1,3,2) < Tuple$new(1,2,3,4)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.