title: How to generate iteratively all subsets for an array in Prolog, and store them into another array?
body: <p>I know that it is very easy recursively with this code</p>
  
  <pre><code>subsets([], []).
  subsets([E|Tail], [E|NTail]):-
     subsets(Tail, NTail).
  subsets([_|Tail], NTail):-
     subsets(Tail, NTail).
  </code></pre>
  
  <p>But I want to store them into an array by generating them iteratively.For example: L=[1,2,3] -> Result = [[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]].</p>