title: How to generate the power-set of a given List?
body: <p>I'm trying to generate a collection of all 2^N - 1 possible combinations of a given List of length N. The collection will map the number of elements in a combination to an ordered list of combinations containing combinations of the specific length. For instance, for the List:</p>
  
  <pre><code>[A, B, C, D]
  </code></pre>
  
  <p>I want to generate the map:</p>
  
  <pre><code>{
      1 -&gt; [{A}, {B}, {C}, {D}]
      2 -&gt; [{A, B}, {A, C}, {A, D}, {B, C}, {B, D}, {C, D}]
      3 -&gt; [{A, B, C}, {A, B, D}, {A, C, D}, {B, C, D}]
      4 -&gt; [{A, B, C, D}]
  }
  </code></pre>
  
  <p>The generated database should maintain the original order (where <code>[]</code> represents an ordered series (<code>List</code>), and <code>{}</code> represents an un-ordered group (<code>Set</code>)), and run as fast as possible.</p>
  
  <p>I was struggling with some recursive code all day (I know the implementation should be recursive) but couldn't get to the bottom of it.</p>
  
  <p>Is there a reference I can use/a ready implementation of such algorithm?</p>