Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the lexicographic successor of a k-subset of a list
ResourceFunction["NextKSubset"][l,s] gives the k-subset of list l that follows the k-subset s in lexicographic order. |
The lexicographic successor of a k-subset of an integer range:
In[1]:= | ![]() |
Out[1]= | ![]() |
NextKSubset[l,s] gives the successor to s in the list of k-subsets (where k is the length of s):
In[2]:= | ![]() |
Out[2]= | ![]() |
In[3]:= | ![]() |
Out[3]= | ![]() |
In[4]:= | ![]() |
Out[4]= | ![]() |
The full list of subsets can also be obtained by iteratively applying NextKSubset, beginning at the initial such subset:
In[5]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License