title: Prolog Finding middle element in List
body: <p>I am trying to make use of prolog predicates and find middle element of a given list. My idea was to cut first and last element of list using recursion.Unfortunately I dont know how to handle recursion call properly.</p>
  
  <pre><code>delete_last(L, L1) :-  
   append(L1, [_], L).
  delete_first(L,L1) :-
      append([_],L1,L).
  check_len(L) :-
     length(L,LEN), \+ 1 is LEN.
  
  
  delete_both([],_):-
      false.
  delete_both([_,_],_) :-
      false.
  delete_both([X],X):-
      true, write('MidElement').
  
  delete_both(L,L2) :-
      delete_first(LT,L2), delete_last(L,LT),check_len(LT) 
      -&gt;write('here should be recursive call only when length is more than one'). 
  </code></pre>
  
  <p>I would be grateful for any help.</p>