 powerset - Maple Help

combinat

 powerset
 construct the power set of a set Calling Sequence powerset(s) Parameters

 s - set or list, or non-negative integer Description

 • 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 ${2}^{n}$ 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]. Examples

 > $\mathrm{with}\left(\mathrm{combinat},\mathrm{powerset}\right)$
 $\left[{\mathrm{powerset}}\right]$ (1)
 > $\mathrm{powerset}\left(3\right)$
 $\left\{{\varnothing }{,}\left\{{1}\right\}{,}\left\{{2}\right\}{,}\left\{{3}\right\}{,}\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}{,}\left\{{2}{,}{3}\right\}{,}\left\{{1}{,}{2}{,}{3}\right\}\right\}$ (2)
 > $\mathrm{powerset}\left(\left\{a,b\right\}\right)$
 $\left\{{\varnothing }{,}\left\{{a}\right\}{,}\left\{{b}\right\}{,}\left\{{a}{,}{b}\right\}\right\}$ (3)
 > $\mathrm{powerset}\left(\left[a,a,b\right]\right)$
 $\left[\left[\right]{,}\left[{a}\right]{,}\left[{b}\right]{,}\left[{a}{,}{b}\right]{,}\left[{a}{,}{a}\right]{,}\left[{a}{,}{a}{,}{b}\right]\right]$ (4)