title: prolog - how to simulate a for-loop
body: <p>I am trying to generate a list such as </p>
  
  <p><code>[X1/1,X2/2,X3/3....Xn/N] with given N.</code></p>
  
  <p>I tried to make a function <code>maketemplate(N,L)</code> that takes <code>N</code> and returns the list of <code>L</code> with items of <code>Xn/N</code> where <code>Xn</code> is a N-th variable, and <code>N</code> is an integer. </p>
  
  <p>As a simpler example, I initially tried to make a list of <code>[1,2,3...N]</code> with given <code>N</code>, but I can't even get that to work.</p>
  
  <pre><code>mysolution(L,N,N).
  mysolution([I|Rest],I,N):-
     I &lt; N,
     I is I+1,
     mysolution(Rest,I+1,N). 
  </code></pre>
  
  <p>How do I simulate a for-loop like operation in prolog?</p>