# Consecutive generation of subsets [duplicate]

It is well known that the array of subsets of even small set is very big. This leads to problems with machine memory. Is there an effective way to generate subsets sequentially?

## marked as duplicate by jkuczm, Feyre, user31159, m_goldberg, ilianSep 10 '16 at 20:19

• Have you seen this? – J. M. is away Jun 16 '16 at 13:41
• Is this a Mathematica-specific question? – Yves Klett Jun 16 '16 at 13:41
• Yes, it's about Mathematica. The answer is interesting, but unwieldy enough. May be in a new version there is a better way? – lesobrod Jun 16 '16 at 13:48
• – jkuczm Jun 16 '16 at 22:52
• @jkuczm That seems close enough to consider a duplicate. Do you disagree? – Mr.Wizard Jul 11 '16 at 16:45

The Subsets function has a third argument to return only some subsets. For example,
Subsets[set, All, {k1, k2}]

returns the k1th through the k2th subsets. This allows for easy sequential generation in blocks. Please check the documentation for details.
• Great! I guess to use Nest and hope it will work. – lesobrod Jun 16 '16 at 14:38
• @Bill You mean NextSubset from Combinatorica? – Szabolcs Jun 16 '16 at 19:08