Learn R Programming

relations (version 0.1-0)

tuple: Tuples

Description

Creation and manipulation of tuples.

Usage

tuple(...)
as.tuple(x)
is.tuple(x)
singleton(...)
pair(...)
triple(...)
tuple_is_singleton(x)
tuple_is_pair(x)
tuple_is_triple(x)
tuple_is_ntuple(x, n)

Arguments

x
An Robject.
n
A non-negative integer.
...
Possibly named Robjects (for pair and triple exactly two and three, respectively.)

Details

These functions represent basic infrastructure for handling tuples of general (R) objects. Class tuple is used in particular to correctly handle cartesian products of sets. Although tuple objects should behave like ordinary vectors, some operations might yield unexpected results since tuple objects are in fact list objects internally.

See Also

set and relation.

Examples

Run this code
## Constructor.
tuple(1,2,3, TRUE)
triple(1,2,3)
pair(Name = "David", Height = 185)
tuple_is_triple(triple(1,2,3))
tuple_is_ntuple(tuple(1,2,3,4), 4)

## Converter.
as.tuple(1:3)

## Operations.
c(tuple("a","b"), 1)
tuple(1,2,3) * tuple(2,3,4)
rep(tuple(1,2,3), 2)

Run the code above in your browser using DataLab