This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Subsets

Subsets[list]
gives a list of all possible subsets of list.
Subsets
gives all subsets containing at most n elements.
Subsets
gives all subsets containing exactly n elements.
Subsets
gives all subsets containing between and elements.
Subsets
limits the result to the first s subsets.
Subsets
gives if possible the ^(th) subset.
  • Subsets[list] gives the power set of list.
  • Subsets[list] orders subsets with shortest first, and later elements in list omitted first.
  • If the elements of list are in the order returned by Sort, then the complete result from Subsets[list] will also be in this order.
  • Subsets gives subsets containing , , ... elements.
  • Subsets gives the same result as Take, provided that the elements specified by spec are present.
All possible subsets (power set):
All possible subsets containing up to 2 elements:
Subsets containing exactly 2 elements:
All possible subsets (power set):
In[1]:=
Click for copyable input
Out[1]=
 
All possible subsets containing up to 2 elements:
In[1]:=
Click for copyable input
Out[1]=
Subsets containing exactly 2 elements:
In[2]:=
Click for copyable input
Out[2]=
The first 5 subsets containing 3 elements:
All subsets with even length:
The 69381^(st) subset:
All subsets of :
The odd-numbered subsets of in reverse order:
Find all ways to pick 3 elements from 4:
Draw lines between all pairs of points in an octagon:
Construct an elementary symmetric polynomial:
All possible subsets of the divisors of 10:
Find integers that have exactly 3 nonzero binary digits:
Join all possible pairs of 20 random points in 3D:
Draw lines between all pairs of points in a cube:
Subsets picks out first the elements that appear first in the input:
Different occurrences of the same element are treated as distinct:
Tuples gives all possible combinations and reorderings of elements:
Subsets[a, b, c]===Take[Subsets[a, b], c] only when all requested items are present:
When items requested by c are missing, the ones present are returned:
To suppress the warning message, use Off:
Polygons formed from all possible triples of random points:
New in 5.1