title: Prolog: Failure driven loops
body: <p>I used the following failure driven loop to list everything without using
  semicolons.</p>
  
  <pre><code>happiness(fred,5).
  happiness(john,3).
  happiness(grace,2).
  
  someGoal(X) :-
          happiness(X,Y), write(Y), tab(4), fail.
  </code></pre>
  
  <p>In query mode, I get this as expected</p>
  
  <pre><code>?- someGoal(_).
  5    3    2 
  </code></pre>
  
  <p>How can I insert these numbers into a list rather than writing them to screen?
  I could not handle this within <code>someGoal</code> since backtracking seems implicit.</p>