title: need explaining code: Repeating Nth element in Prolog
body: <p>I'm writing a program to repeat an element in Prolog, for example</p>
  
  <pre><code>repeat_nth(1, [H|T], [H,H|T]).
  repeat_nth(N, [H|T], [H|T1]) :-
      N &gt; 1,
      N1 is N-1,
      repeat_nth(N1, T, T1).
  </code></pre>
  
  <p>I can understand everything on here up until the last line. If anyone could explain in simple terms what's happening that'd be great. Thankyou.</p>