Skip to main content
5 votes

How can I permute pair of elements in a list?

res = MapAt[Reverse, {All, 2 ;; -1}] @ (Transpose[{Cases[list, _Symbol], #}] & /@ Permutations[Cases[list, {__}]]); Join @@@ res // Column
eldo's user avatar
  • 78.3k
5 votes
Accepted

How to replace sequences in a list based on specific patterns?

SequenceReplace[list, (x : {A1, B1} | {B1, A1} | {A2, B2} | {B2, A2}) -> x] (* {V1, {A1, B1}, {A2, B2}, {B1 A1}, V2} *) If you also want to handle ...
Najib Idrissi's user avatar
4 votes
Accepted

How can I permute pair of elements in a list?

...
A. Kato's user avatar
  • 916
3 votes

How to replace sequences in a list based on specific patterns?

It is not clear from the question, but I understand that only A? and B? are combined, but somehow A? and V? are not. Then, the following code will work for a data containing A3 and B3 as well. (I ...
A. Kato's user avatar
  • 916
2 votes

How can I permute pair of elements in a list?

Just for somethinng different: ...
ubpdqn's user avatar
  • 62.1k
1 vote

How can I permute pair of elements in a list?

An attempt ...
user1066's user avatar
  • 20.2k

Only top scored, non community-wiki answers of a minimum length are eligible