title: Prolog find all subsets matching condition
body: <p>I'm trying to solve a problem in SWI-Prolog. I have a list of suitable elements (constants) obtained with.</p>
  
  <pre><code>suitables(L) :- setof(X, isSuitable(X), L).
  </code></pre>
  
  <p>Each element from above has a score via a functor, and I need all the subsets that have a score > 10. I know how to get the score sum:</p>
  
  <pre><code>scoreSum([], 0).
  scoreSum([H,T], Tot) :- getScore(H,F),scoreSum(T, Rest), Tot is F+Rest.
  </code></pre>
  
  <p>And the condition can be expressed like this:</p>
  
  <pre><code>cond(L) :- scoreSum(L, R), R &gt; 10.
  </code></pre>
  
  <p>How do I get all the subsets matching the given condition? I can get the subsets based on the answer <a href="https://stackoverflow.com/questions/4578755/permuted-combinations-of-the-elements-of-a-list-prolog">here</a>, but how do I iterate over that result to get only the subsets matching the condition?</p>