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.
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.
function([X|_]) :- \ + X,!.
function([X]):-X,!.
function([_|XS]):- function(XS),!,helper(XS).
helper([X]):- X,!.
helper([_|YS]):- helper(YS),!.
I would appreciate if you could help me. Thanks!