1
$\begingroup$

Given this,

lst0 = <|{1, 5, 2, 0, 2, 9} -> g1, {1, 4, 1, 1, 0, 0} -> 
 g2, {7, 1, 3, 2, 3, 2} -> g3, {1, 5, 2, 1, 2, 0} -> 
 g2, {1, 4, 0, 0, 1, 1} -> g2, {1, 5, 2, 9, 2, 0} -> 
 g1, {1, 5, 3, 2, 2, 3} -> g3, {1, 5, 13, 2, 2, 3} -> g1|>;

Based on the Keys of above lst0, some elements in this Association should be \ deleted. The rules are as follows, If there are two keys in lst1 meeting such conditions,

key1[[1 ;; 2]] == key2[[1 ;; 2]]  && 
key1[[3 ;; 4]] == key2[[5 ;; 6]]  && 
key1[[5 ;; 6]] == key2[[3 ;; 4]]  && (Symmetric character)

then key1 element or key2 element should be deleted in lst0 (In fact,they both should have the same values. But here we cannot use their values to delete one of them.). One possible obatined lst1 should be like this,

lst1 = <|{1, 5, 2, 0, 2, 9} -> g1, {1, 4, 1, 1, 0, 0} -> 
g2, {7, 1, 3, 2, 3, 2} -> g3, {1, 5, 2, 1, 2, 0} -> 
g2, {1, 5, 3, 2, 2, 3} -> g3, {1, 5, 13, 2, 2, 3} -> g1|>;

Any idea about this ? A huge list is needed to be done. Quicker is better.

$\endgroup$
2
$\begingroup$

Perhaps:

ClearAll[foo]
foo[{x_, y_, a_, b_, c_, d_}]:= foo[{x, y, c, d, a, b}] = {x, y, a, b, c, d}

KeyMap[foo, lst0]

<|{1, 5, 2, 0, 2, 9} -> g1, {1, 4, 1, 1, 0, 0} -> g2, {7, 1, 3, 2, 3, 2} -> g3, {1, 5, 2, 1, 2, 0} -> g2, {1, 5, 3, 2, 2, 3} -> g3, {1, 5, 13, 2, 2, 3} -> g1|>

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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