combinat
powerset
construct the power set of a set
Calling Sequence
Parameters
Description
Examples
powerset(s)
s
-
set or list, or non-negative integer
The powerset(s) calling sequence constructs the power set of a set, list, or non-negative integer.
If s is a set, then powerset command returns the power set of s, that is, a set consisting of all the subsets of s. The power set has 2n entries, where n is the number of elements in s.
If s is a non-negative integer, powerset interprets it as a set of the first s integers.
If s is a list, powerset returns a list of all the sublists of s. The number of sublists depends on the multiplicities of s.
To iterate through the subsets of a given set without generating all subsets beforehand, use combinat[subsets].
with⁡combinat,powerset
powerset⁡3
∅,1,2,3,1,2,1,3,2,3,1,2,3
powerset⁡a,b
∅,a,b,a,b
powerset⁡a,a,b
,a,b,a,b,a,a,a,a,b
See Also
combinat[choose]
combinat[subsets]
Download Help Document