# Again the For loops [duplicate]

I failed to use DeleteCases to eliminate from a list of pairs when they are the same {a,b} {a,b} or {a,b} {b,a}. To test finally I wrote the procedure using For For and If and Reap Saw to identify the elements that i had to delete ... but I can not found the way this is what I did including the sample generator

Clear["Global*"]

Remove["Global*"]

ldp = Range[11, 99];

ldpp = RandomChoice[ldp, 200];

ldppp = Partition[ldpp, 2, 1, -1];

For[i = 1, i < Length[ldppp], i++,
For[j = i + 1, j <= Length[ldppp], j++,
If[Or[ldppp[[i]] == ldppp[[j]],
ldppp[[i]] == Reverse[ldppp[[j]]]], Print[ldppp[[i]], ldppp[[j]]]]
]
]

Reap[
For[i = 1, i < Length[ldppp], i++,
For[j = i + 1, j <= Length[ldppp], j++,
If[Or[ldppp[[i]] == ldppp[[j]],
ldppp[[i]] == Reverse[ldppp[[j]]]],
Sow[{ldppp[[i]], ldppp[[j]]}]]]
]
]


I would appreciate some trick to move to functional style

• DeleteDuplicatesBy[ldppp, Sort]?
– Kuba
Jan 26, 2018 at 21:46
• I thought must be simple but stay focused en DeleteCases... feel like the skier who bumps in the only tree in the track! thanks @Kuba Jan 26, 2018 at 21:51
• No worries. p.s. just leaving another closely related: mathematica.stackexchange.com/q/140571/5478
– Kuba
Jan 26, 2018 at 21:59
• DeleteCases[{{a,b},{a,c},{b,a}}, {a,b}|{b,a}] gives you {a,c} if that helps
– Bill
Jan 26, 2018 at 23:04