title: Prolog program that deletes every n-th element from a list
body: <p>Could you help me solve the following?</p>
  
  <blockquote>
    <p>Write a ternary predicate <code>delete_nth</code> that deletes every n-th element from a list.</p>
  </blockquote>
  
  <p>Sample runs:</p>
  
  <pre><code>?‐ delete_nth([a,b,c,d,e,f],2,L).
  L = [a, c, e] ;
  false
  ?‐ delete_nth([a,b,c,d,e,f],1,L).
  L = [] ;
  false
  ?‐ delete_nth([a,b,c,d,e,f],0,L).
  false
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>listnum([],0).
  listnum([_|L],N) :-
     listnum(L,N1),
     N is N1+1.
  
  delete_nth([],_,_).
  delete_nth([X|L],C,L1) :- 
     listnum(L,S),
     Num is S+1,
     (  C&gt;0
     -&gt; Y is round(Num/C),Y=0
     -&gt; delete_nth(L,C,L1)
     ;  delete_nth(L,C,[X|L1])
     ).
  </code></pre>