title: How to append number to list in prolog?
body: <p>I am very new to Prolog. My goal is to append integers to a list, up to a bound:
  if the function receives <code>N</code>, it outputs a list <code>[N, N-1, ... , 1]</code>.</p>
  
  <p>Here is my code: </p>
  
  <pre><code>myAppend(0, L) :- append([],[], L).
  myAppend(N, L) :- append([N], [], L), N1 is N - 1, myAppend(N1, L).
  </code></pre>
  
  <p>invoking the function above returns false for every <code>N=\=0</code>:</p>
  
  <pre><code>51 ?- myAppend(0,L).
  L = [] ;
  false.
  
  52 ?- myAppend(2,L).
  false. &lt;-------------------- was expecting L = [2, 1]
  
  53 ?-
  </code></pre>
  
  <p>However, when i changed my function to (put a dot <code>.</code> instead of <code>,</code> after call to <code>append</code> in the 2nd rule):</p>
  
  <pre><code>myAppend(0, L) :- append([],[],L).
  myAppend(N,L) :-  append([N], [], L). N1 is N - 1, myAppend(N1, L). 
  </code></pre>
  
  <p>I got the following output:</p>
  
  <pre><code>51 ?- myAppend(0,L).
  L = [] ;
  false.
  
  52 ?- myAppend(4,L).
  L = [4] . &lt;-------------- was expecting [4, 3, 2, 1]
  
  53 ?-
  </code></pre>
  
  <p>I am unable to understand why in the 1st implementation I was receiving <code>false</code>, although the logic behind it is correct?</p>