Returns the union of objects inheriting from class Set.
setunion(..., simplify = TRUE) # S3 method for Set +(x, y) # S3 method for Set |(x, y)
... | Sets |
---|---|
simplify | logical, if |
x, y |
An object inheriting from Set containing the union of supplied sets.
The union of \(N\) sets, \(X1, ..., XN\), is defined as the set of elements that exist in one or more sets, $$U = \{x : x \epsilon X1 \quad or \quad x \epsilon X2 \quad or \quad...\quad or \quad x \epsilon XN\}$$
The union of multiple ConditionalSets is given by combining their defining functions by an
'or', |
, operator. See examples.
The union of fuzzy and crisp sets first coerces fuzzy sets to crisp sets by finding their support.
Other operators:
powerset()
,
setcomplement()
,
setintersect()
,
setpower()
,
setproduct()
,
setsymdiff()
# union of Sets Set$new(-2:4) + Set$new(2:5) #> {-1, -2,...,4, 5} setunion(Set$new(1, 4, "a"), Set$new("a", 6)) #> {1, 4, 6, a} Set$new(1, 2) + Set$new("a", 1i) + Set$new(9) #> {0+1i, 1,...,9, a} # union of intervals Interval$new(1, 10) + Interval$new(5, 15) + Interval$new(20, 30) #> [1,15] ∪ [20,30] Interval$new(1, 2, type = "()") + Interval$new(2, 3, type = "(]") #> (1,2) ∪ (2,3] Interval$new(1, 5, class = "integer") + Interval$new(2, 7, class = "integer") #> Called from: FUN(X[[i]], ...) #> debug: if (!testSet(y)) { #> return(FALSE) #> } #> debug: if (testFuzzy(y)) { #> if (!all(y$membership() == 1)) { #> return(FALSE) #> } #> } #> debug: if (testConditionalSet(y)) { #> return(FALSE) #> } else if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> debug: return(all(comp)) #> Called from: FUN(X[[i]], ...) #> debug: if (!testSet(y)) { #> return(FALSE) #> } #> debug: if (testFuzzy(y)) { #> if (!all(y$membership() == 1)) { #> return(FALSE) #> } #> } #> debug: if (testConditionalSet(y)) { #> return(FALSE) #> } else if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> debug: return(all(comp)) #> {1, 2,...,6, 7} # union of mixed types Set$new(1:10) + Interval$new(5, 15) #> Called from: FUN(X[[i]], ...) #> debug: if (!testSet(y)) { #> return(FALSE) #> } #> debug: if (testFuzzy(y)) { #> if (!all(y$membership() == 1)) { #> return(FALSE) #> } #> } #> debug: if (testConditionalSet(y)) { #> return(FALSE) #> } else if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } else { #> return(FALSE) #> } #> debug: return(FALSE) #> {1, 10,...,8, 9} ∪ [5,15] Set$new(1:10) + Interval$new(5, 15, class = "integer") #> Called from: FUN(X[[i]], ...) #> debug: if (!testSet(y)) { #> return(FALSE) #> } #> debug: if (testFuzzy(y)) { #> if (!all(y$membership() == 1)) { #> return(FALSE) #> } #> } #> debug: if (testConditionalSet(y)) { #> return(FALSE) #> } else if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> debug: return(all(comp)) #> Called from: FUN(X[[i]], ...) #> debug: if (!testSet(y)) { #> return(FALSE) #> } #> debug: if (testFuzzy(y)) { #> if (!all(y$membership() == 1)) { #> return(FALSE) #> } #> } #> debug: if (testConditionalSet(y)) { #> return(FALSE) #> } else if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> debug: return(all(comp)) #> {1, 10,...,8, 9} Set$new(5, 7) | Tuple$new(6, 8, 7) #> {5, 6, 7, 8} # union of FuzzySet FuzzySet$new(1, 0.1, 2, 0.5) + Set$new(2:5) #> Called from: FUN(X[[i]], ...) #> debug: if (!testSet(y)) { #> return(FALSE) #> } #> debug: if (testFuzzy(y)) { #> if (!all(y$membership() == 1)) { #> return(FALSE) #> } #> } #> debug: if (testConditionalSet(y)) { #> return(FALSE) #> } else if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> debug: return(all(comp)) #> Called from: FUN(X[[i]], ...) #> debug: if (!testSet(y)) { #> return(FALSE) #> } #> debug: if (testFuzzy(y)) { #> if (!all(y$membership() == 1)) { #> return(FALSE) #> } #> } #> debug: if (testConditionalSet(y)) { #> return(FALSE) #> } else if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (testInterval(y)) { #> if (testCountablyFinite(y)) { #> return(all(suppressWarnings(y$elements %in% self$elements & #> self$elements %in% y$elements))) #> } #> else { #> return(FALSE) #> } #> } else if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: if (sum(testEmpty(self), testEmpty(y)) == 1) { #> return(FALSE) #> } else { #> comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> return(all(comp)) #> } #> debug: comp <- suppressWarnings(y$.__enclos_env__$private$.str_elements %in% #> private$.str_elements & private$.str_elements %in% y$.__enclos_env__$private$.str_elements) #> debug: return(all(comp)) #> {1, 2,...,4, 5} # union of conditional sets ConditionalSet$new(function(x, y) x >= y) + ConditionalSet$new(function(x, y) x == y) + ConditionalSet$new(function(x) x == 2) #> {x ∈ 𝕍, y ∈ 𝕍 : x >= y | x == y | x == 2} # union of special sets PosReals$new() + NegReals$new() #> ℝ Set$new(-Inf, Inf) + Reals$new() #> ℝ ∪ {-∞, +∞}