I want to create a rule in prolog that checks if there\'s a repeated number in a list.
For example:
[1,2,3,4]
tru
Very Simple Answer...
The code:
unique([]). unique([_,[]]). unique([H|T]):-not(member(H,T)),unique(T).
Tests:
?-unique([1,2,3,4]). true. ?-unique([1,2,3,3]). false. ?-unique([a,b,12,d]). true ?-unique([a,b,a]). false