## operations between sets
X1 <- hset(c(2,3,4)); X2 <- hset(c(2,3,5))
intersection(X1, X2, semantic = "value") # X1 %&~% X2
union(X1, X2, semantic = "value") # X1 %|~% X2
difference(X1, X2, semantic = "value") # X1 %-~% X2
symmdiff(X1, X2, semantic = "value") # X1 %--~% X2
setsum(X1, X2, semantic = "value") # X1 %+~% X2
## semantic of operations
X1 # same as before, as value semantic is used so far
union(X1, X2) # union with reference semantic
X1 # result of previous computation
## operations between multisets
Y1 <- hset(c(2,3,4), c(2,1,.5)); Y2 <- hset(c(2,3,5), c(1,1,.5))
intersection(Y1, Y2, semantic = "value") # Y1 %&~% Y2
union(Y1, Y2, semantic = "value") # Y1 %|~% Y2
difference(Y1, Y2, semantic = "value") # Y1 %-~% Y2
symmdiff(Y1, Y2, semantic = "value") # Y1 %--~% Y2
setsum(Y1, Y2, semantic = "value") # Y1 %+~% Y2
## mixed operation
Y3 <- setsum(Y1, X2, semantic = "value")
Y3
Run the code above in your browser using DataLab