title: How do I find all solutions to a goal in Prolog?
body: <p>I have predicate P1 that returns values one after the other like this:</p>
  
  <pre><code>-? P1(ARGUMENTS, RETURN).
  -? RETURN = 1;
  -? RETURN = 2;
  -? RETURN = 3;
  -? fail.
  </code></pre>
  
  <p>I also have another predicate called P2:</p>
  
  <pre><code>P2(ARGUMENTS, LIST) :- P1(ARGUMENTS, RETURN),... % SOMEHOW HERE I NEED TO INSERT ALL VALUES OF RETURN TO LIST.
  </code></pre>
  
  <p>How do find all of the values of <code>RETURN</code> and assign them to <code>LIST</code>?</p>