 <p>The two clauses: <code>NewCount is Count + 1</code> and <code>increment(NewCount,Count)</code> basically have the same meaning. You didn't make clear that <code>Count</code> is an input variable and it has a base case of <code>1</code>, so Prolog didn't know where to start unifying values for it. For example, you should use <code>Count</code> as an input argument as follows (it doesn't change much if compared with your version):</p> <pre><code>order([],[], _). order([Head|Tail],[(Count,Head)|NewTail], Count):- NewCount is Count + 1, order(Tail, NewTail, NewCount). order(List, Result ):- order(List, Result, 1). </code></pre>