title: Prolog XOR on elements of list
body: <p>I am new in Prolog and I would like to apply XOR operation on elements of given list of length n. The predicate should return True if list contains some false elements in the first n-1 element or if last element is True.</p>
  
  <p>I have written the following code so far, but it does not work properly such as for the query ?- function([true,false,false]) the predicate should return True but it returns false.</p>
  
  <pre><code>function([X|_]) :-  \ + X,!.
  function([X]):-X,!.
  function([_|XS]):- function(XS),!,helper(XS).
  
  helper([X]):- X,!.
  helper([_|YS]):- helper(YS),!.
  </code></pre>
  
  <p>I would appreciate if you could help me. Thanks!</p>