title: Prolog Counter Problem
body: <p>I am trying to write a procedure <code>order(List,Result)</code> that has a <code>List</code> as input and returns a list <code>Result</code> of ordered pairs such that: </p>
  
  <ul>
  <li>the first element of the ordered pair is the position of the pair in the list, and</li>
  <li>the second element of the ordered pair is the element from List n the corresponding             position.</li>
  </ul>
  
  <p>Example: </p>
  
  <p>if <code>List = [a,b,c,d]</code>, the procedure order(List,Result) outputs the list:
  <code>Result = [(1,a), (2,b),(3,c),(4,d)]</code>.</p>
  
  <p>I am struggling with the counter for the position of the pair in the list. I have made attempts such as: </p>
  
  <pre><code>increment(Accum,Total):-
          Total is Accum + 1.
  order([],[]).
  order([Head|Tail],Result):-
          order(Tail, NewTail),
          NewCount is Count + 1,
          increment(NewCount,Count),
          Result = [(Count,Head)|NewTail].
  </code></pre>
  
  <p>Please help anyone?</p>