# normal return type is a list of vectors
createPowerset(c("Alice", "Bob"), includeEmptySet = FALSE)
## [[1]]
## [1] "Alice" "Bob"
##
## [[2]]
## [1] "Alice"
##
## [[3]]
## [1] "Bob"
# instead of creating a list, print the power set such that it can be copy-pasted
# and used to create a new PowerRelation object
createPowerset(letters[1:4], result = "print")
# prints
# as.PowerRelation("
# abcd
# > abc
# > abd
# > acd
# > bcd
# > ab
# ...
# > {}
# ")
createPowerset(letters[1:3], includeEmptySet = FALSE, result = "printCompact")
# as.PowerRelation("abc > ab > ac > bc > a > b > c")
# create the same string as before, but now copy it to the clipboard instead
if(interactive()) {
createPowerset(1:3, result = "copyCompact")
}
# Note that as.PowerRelation(character) only assumes single-char elements.
# As such, the generated function call string with multi-character names
# looks a little different.
createPowerset(c("Alice", "Bob"), result = "print")
# PowerRelation(rlang::list2(
# list(c("Alice", "Bob")),
# list(c("Alice")),
# list(c("Bob")),
# list(c()),
# ))
Run the code above in your browser using DataLab