How to remove duplicate elements? I want to delete all the same elements in a list. For example, list {1,2,1,2,3,4,5,1}, I want to get {3,4,5}.
And using DeleteDuplicates function can not achieve the desired purpose:
DeleteDuplicates[{1, 2, 1, 2, 3, 4, 5, 1}]
I know this method at present: {1, 2, 1, 2, 3, 4, 5, 1} // Tally // Cases [{x_, 1}:> x], but I also want to know more ingenious methods.
Tally/*Casesmethod is pretty cool! – Roman Mar 01 '20 at 09:27{1, 2, 1, 2, 3, 4, 5, 1} //. {a___, b_, c___, b_, d___} :> DeleteCases[{a, c, d}, b]. – AccidentalFourierTransform Mar 01 '20 at 21:05Reap[Sow[1,list], _, Pick[#1,#2, {1}]&][[2]]– user1066 Mar 02 '20 at 18:50