A convenience wrapper for the n-ary cartesian product of a Set
by itself,
possibly multiple times.
setpower(x, power, simplify = FALSE, nest = FALSE) # S3 method for Set ^(x, power)
x | Set |
---|---|
power | power to raise set to, if |
simplify | logical, if |
nest | logical, if |
An R6 object of class Set
or ExponentSet
inheriting from ProductSet
.
See the details of setproduct for a longer discussion on the use of the nest
argument, in particular with regards to n-ary cartesian products vs. 'standard' cartesian
products.
Other operators:
powerset()
,
setcomplement()
,
setintersect()
,
setproduct()
,
setsymdiff()
,
setunion()
# Power of a Set setpower(Set$new(1, 2), 3, simplify = FALSE) #> {1, 2}^3 setpower(Set$new(1, 2), 3, simplify = TRUE) #> {(1, 1, 1), (1, 1, 2),...,(2, 2, 1), (2, 2, 2)} Set$new(1, 2)^3 #> {1, 2}^3 # Power of an interval Interval$new(2, 5)^5 #> [2,5]^5 Reals$new()^3 #> ℝ^3 # Use tuples for contains (PosNaturals$new()^3)$contains(Tuple$new(1, 2, 3)) #> [1] TRUE # Power of ConditionalSet is meaningless ConditionalSet$new(function(x) TRUE)^2 #> {x ∈ 𝕍}^2 # Power of FuzzySet FuzzySet$new(1, 0.1, 2, 0.5)^2 #> {1(0.1), 2(0.5)}^2 # Variable length x <- Interval$new(0, 1)^"n" x$contains(Tuple$new(0)) #> [1] TRUE x$contains(Tuple$new(0, 1)) #> [1] TRUE x$contains(Tuple$new(0, 1, 0, 0, 1, 1, 0)) #> [1] TRUE x$contains(list(Tuple$new(0, 2), Tuple$new(1, 1))) #> [1] FALSE TRUE