title: PROLOG rule returns only first match
body: <p>I'm trying to implement a findall predicate in Prolog (yes I know it's built in, this is for an assignment). </p>
  
  <p>It is written as follows: </p>
  
  <pre><code>my_findall(N,P,Pred,L) :- Pred, not(new(N,P)), !, assert(new(N,P)), my_findall(N1,P1,Pred,L1), L=[N,P,L1], retract(new(N,P)).
  my_findall(_,_,_,  []).
  </code></pre>
  
  <p>For some reason it only gives me the first solution and stops there, as if the second call to my_findall fails. As I understand, the backtracking mechanism should go over all the possible options, which should include all the options for calling Pred(N,P), so even though the second call should fail on the first try (first option tried for Pred has already been asserted), it should try all the other options first before giving up and going to my_findall((<em>,</em>),_,  []).</p>
  
  <p>If that's not how it works, is there a way to force this kind of behavior without completely rewriting the solution? </p>