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.
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.
Sort the list using
sort/2
. It removes duplicates, so if the sorted list is exactly one shorter, you had exactly one pair.Finding the duplicate pair is another question altogether.