Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the next subset of a given set in canonical order
ResourceFunction["NextSubset"][l,s] gives the subset of l following the subset s when the subsets are sorted in canonical order. |
Get the subset of {1,2,3} following the subset {1,2} in canonical order:
In[1]:= |
Out[1]= |
Get the subset following another subset in canonical ordering:
In[2]:= |
Out[2]= |
This is not the same as the next subset in lexicographic order, as can be obtained with the resource function NextLexicographicSubset:
In[3]:= |
Out[3]= |
The full list of lexicographically-ordered subsets can be obtained using the resource function LexicographicSubsets:
In[4]:= |
Out[5]= |
Subsets of {1,2,3} in canonical order generated sequentially using NextSubset:
In[6]:= |
Out[6]= |
Compare:
In[7]:= |
Out[7]= |
In[8]:= |
Out[8]= |
This work is licensed under a Creative Commons Attribution 4.0 International License