Im wondering how can i write a predicate /1 which determines if a given list has duplicates or is unique without pre-defined/built-in predicates?
myFunc([a,b,c,d]) = true
myFunc([a,b,a,d]) = false
What i have so far is :
myFunc([X|Y]) :- helpFunc(Y,X).
myFunc([]).
helpFunc([],_).
helpFunc([Y|X], Y) :- helpFunc(X,Y).
This returns true only if there are consecutive repeated element in the list.
ex.
myFunc([1,3,a,4,b]) = false -- > should return true
myFunc([1,3,a,3,b]) = false -- > should return false
--
myFunc([3,3,3,3]) = true
any ideas ?