7
$\begingroup$

Suppose I have a list,

  {12 -> -12, 13 -> -13, 14 -> -14, 15 -> -15, 9 -> -9, 11 -> -11, 
  13 -> -13, 15 -> -15, 5 -> -5, 7 -> -7, 13 -> -13, 15 -> -15, 
  3 -> -3, 7 -> -7, 11 -> -11, 15 -> -15}

I want to remove elements which occur even times completely and keep a single instance of elements occurring odd times. That is, I want to end up with the list,

  {12 -> -12, 13 -> -13, 14 -> -14, 9 -> -9, 5 -> -5, 3 -> -3}
$\endgroup$
0

1 Answer 1

10
$\begingroup$

You could use

Keys[Select[Counts[list],OddQ]]

where list is your list.

$\endgroup$
1
  • $\begingroup$ That works! Thanks!! $\endgroup$
    – Dotman
    Commented Aug 3, 2022 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.