title: Split a list into two sublists in all possible ways
body: <p>I have a list of variable size, for example</p>
  
  <pre><code>[1, 2, 3, 4]
  </code></pre>
  
  <p>and I want to get every possible way to split this list into two:</p>
  
  <pre><code>([], [1, 2, 3, 4])
  ([1], [2, 3, 4])
  ([2], [1, 3, 4])
  ([3], [1, 2, 4])
  ([4], [1, 2, 3])
  ([1, 2], [3, 4])
  ([1, 3], [2, 4])
  ([1, 4], [2, 3])
  ([2, 3], [1, 4])
  ([2, 4], [1, 3])
  ([3, 4], [1, 2])
  ([1, 2, 3], [4])
  ([1, 2, 4], [3])
  ([1, 3, 4], [2])
  ([2, 3, 4], [1])
  ([1, 2, 3, 4], [])
  </code></pre>
  
  <p>I'm pretty sure this is not an unknown problem and there is probably an algorithm for this, however I could not find one. Also, this should not use any external libraries but work with simple language features (loops, conditions, methods/functions, variables, ...) found in most languages.</p>
  
  <p>I've written a hackish solution in Python:</p>
  
  <pre><code>def get_all(objects):
      for i in range(1, len(objects)):
          for a in combinations(objects, i):
              for b in combinations([obj for obj in objects if obj not in up], len(objects) - i):
                  yield State(up, down)
      if objects:
          yield State([], objects)
          yield State(objects, [])
  </code></pre>
  
  <p>However, it uses library features and is not very nice looking in general.</p>