Does anybody know how I can go about determining/ensuring that there is exactly one duplicate element in a prolog list?
I am studying for a test.
one_duplicate(L) :- sort(L, Sorted), length(L, Len), length(Sorted, SortedLen), Len =:= SortedLen + 1.