title: Permuted combinations of the elements of a list - Prolog
body: <p>How can I generate all the possible combinations of the elements of a list?  </p>
  
  <p>For example, given the list <code>[1,2,3]</code>, I want to design a predicate with the form <code>comb([1,2,3], L).</code> which should return the following answer for <code>L</code>:</p>
  
  <pre><code>[1]  
  [2]  
  [3]  
  [1,2]  
  [2,1]  
  [1,3]  
  [3,1]  
  [2,3] 
  [3,2]  
  [1,2,3]  
  [1,3,2]  
  [2,1,3]  
  [2,3,1]  
  [3,1,2]  
  [3,2,1] 
  </code></pre>