title: Prolog if/else statement with recursion
body: <p>I'm new to prolog and I'm trying to figure out how I can use if/else statement and recursion.  To illustrate, I've written a simple prolog program. The program is useless (in that its functionality is useless), but it helps me illustrate my problem.  The program takes a list, examines the head of the list, sees if it's the last element; if it's not, it adds the head to a temporary list variable and runs the program in recursion using the Tail of the list.  It should output the list in the end.  The program:</p>
  
  <pre><code> gothrough([H|T], B, C):-
        append(B,H,B),
        (  (T == [])
        -&gt; C=B
        ;  gothrough(T, B, C)
        ).
  </code></pre>
  
  <p>The call: <code>gothrough([sample, phrase, here], [], C).</code></p>
  
  <p>Expected output: <code>C = [sample, phrase, here]</code></p>
  
  <p>Current output: <code>no</code></p>
  
  <p>Any help on what I'm doing wrong?</p>
  
  <p>Thanks!</p>