power_set: power_set()

View source: R/power_set.R

power_setR Documentation

power_set()

Description

A function that gives the power set P(S) of any non empty set S.

Usage

power_set(n, ordinal = FALSE)

Arguments

n

an integer. The cardinal of the set

ordinal

a boolean. If TRUE the power set is only composed of subsets of consecutive elements, FALSE (by default) otherwise.

Value

A list of 2^n -1 subsets (The empty set is excluded)

Author(s)

Gregory Guernec

otrecod.pkg@gmail.com

References

Devlin, Keith J (1979). Fundamentals of contemporary set theory. Universitext. Springer-Verlag

Examples

# Powerset of set of 4 elements
set1 <- power_set(4)

# Powerset of set of 4 elements by only keeping
# subsets of consecutive elements
set2 <- power_set(4, ordinal = TRUE)


OTrecod documentation built on Oct. 5, 2022, 5:06 p.m.