title: Get all sets of list in prolog
body: <p>How can I generate all the possible sets of the elements of a list with current length?   </p>
  
  <pre><code>?- get_set(X, [1,2,3]).  
  X = [1,1,1] ;  
  X = [1,1,2] ;  
  X = [1,1,3] ;  
  X = [1,2,1] ;  
  X = [1,2,2] ;  
  X = [1,2,3] ;  
  X = [1,3,1] ;  
  X = [1,3,2] ;  
  X = [1,3,3] ;  
  .....  
  X = [3,3,2] ;  
  X = [3,3,3].  
  </code></pre>
  
  <p>UPD: there is good answer given by Sharky.
  But maybe it's not the best. Here is another:</p>
  
  <pre><code>get_set(X,L) :- get_set(X,L,L).
  
  get_set([],[],_).
  get_set([X|Xs],[_|T],L) :- member(X,L), get_set(Xs,T,L).
  </code></pre>