title: Reversing a List in Prolog
body: <p>I have finished a homework assignment for my programming class.  I was supposed to create a Prolog program that reverses a list.  I, however, am having trouble understanding why exactly it works.  </p>
  
  <pre><code>%1. reverse a list
  %[a,b,c]-&gt;[c,b,a]
  
  %reverse(list, rev_List).
  reverse([],[]).  %reverse of empty is empty - base case
  reverse([H|T], RevList):-
      reverse(T, RevT), conc(RevT, [H], RevList).  %concatenation
  </code></pre>
  
  <p>What exactly is RevT in this case?  I know it is supposed to represent the reverse of T or the rest of the given list, but I don't see how it could have any value as I haven't assigned it to anything.  Does it just serve the same purpose as RevList but for each recursive call?  </p>
  
  <p>Also, why do I have to use [H] instead of just H in my conc() function call?  Doesn't H refer to the head of the list (ex:  [H])?  Or does it just refer to the item at the head of the list (just H)?</p>
  
  <p>Please help clear this up for me.  I am struggling to understand the logic behind this type of programming.</p>