Say if I have two sets of vectors, for example:
$$v_{1}=((0,0,0),(0,1,0),(0,0,1),(1,1,1))$$
$$v_{2}=((0,1,0),(1,1,1),(0,0,0),(0,0,1))$$
I want to find a way of verifying that both $v_{1}$ and $v_{2}$ contain the same vectors, regardless of order.
I'm not sure how to do it, below are attempts that did not work:
v1={{0,0,0},{0,1,0},{0,0,1},{1,1,1}}
v2={{0,1,0},{1,1,1},{0,0,0},{0,0,1}}
TrueQ[OrderlessPatternSequence[v1]==OrderlessPatternSequence[v2]]
Equal[Permutations[v1],Permutations[v2]]
Intersection[v1,v2]
Union[v1] === Union[v2]
should be okay. $\endgroup$OrderlessPatternSequence
you can useMatchQ[v1, {OrderlessPatternSequence[Sequence@@v2]}]
$\endgroup$Union
will sort as well as delete the duplicates. Yes, you are interpreting it correctly. I guess the ambiguity exists as you used the wordset
instead oflist
. $\endgroup$Set
construct but only aList
construct. If, however, you use functions intended for sets, such asUnion
,Intersection
,Complement
, then these functions will sort (since order does not matter in a set) and will delete duplicates (since a set contains unique elements only). $\endgroup$