Have you tried the codes in this thread and Lee's page (which describes what they do)? They all literally take one list, then extract those values so the new list contains unique values.
What you're after is a way to get only the values which do not have duplicates. A very similar approach would work here:
Using the recursive method:
- Start with the 1st item in the list - stop if the list is empty.
- Check if it is inside the rest of the list (use the vl-some method as per my iterative approach).
- If not (i.e. unique), then cons it into the result of calling the same function using the rest of the list.
- Else (if duplicate found) only call the same function on the rest of the list.
Using the iterative approach:
- Start with the 1st item in the list.
- Check if it is inside the rest of the list (use the vl-some method as per my iterative approach).
- If not (i.e. unique), then cons it into the result.
- No else portion.
- Change the list to only contain the rest of the list and repeat the loop.
- After loop, return the result variable reversed to get the values in the original order.
Doing it for the duplicate counter is a bit more complicated. You'd need another list which counts how many times a particular value was found in the list. Then extract only those with the count the same number as specified.