I have been trying to remove duplicates elements from a list using delete cases instead of the conventional deleteDuplicates function. I wrote something like

DeleteCases[list,x_ y_/;(x-y)==0] which obviously did not work. How do I iterate over different elements in the list without using for loops or while ?


closed as off-topic by MarcoB, happy fish, gwr, bbgodfrey, ubpdqn Mar 19 '17 at 10:32

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – bbgodfrey, ubpdqn
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Are you sure you don't want DeleteDuplicates? You can supply a second argument, i.e., DeleteDuplicates[list,#-#2==0.&] $\endgroup$ – b3m2a1 Mar 14 '17 at 6:21
  • 1
    $\begingroup$ Why not use Union? $\endgroup$ – Anjan Kumar Mar 14 '17 at 6:21
  • 1
    $\begingroup$ @AnjanKumar Union will apply a sorting to the list. That's unnecessary if he just wants to remove the duplicates. There DeleteDuplicates is sufficient. $\endgroup$ – b3m2a1 Mar 14 '17 at 6:23
  • $\begingroup$ @AbheshekPal asked about removing the same elements without using cycles. And he wrote about deleteDublicates. I thought it is not appropriate for the your task $\endgroup$ – Kirill Belov Mar 14 '17 at 7:51

Browse other questions tagged or ask your own question.