Consider the two lists
list1={1,2,a[1],8,b[4],9};
list2={8,b[4],9,1,2,a[1]};
it is evident by inspection that list2
is just a cyclic rotation of list1
. Considering an equivalence class of lists under cyclic rotations, I would like to have a function cycRot[x_List]
that takes a list and returns a cyclically rotated representative of that list, which would be independent of the initial cyclic order of the list. Such that
cycRot[list1]==cycRot[list2]
True
is guaranteed (the exact resulting rotation is irrelevant as long as the function returns the same result for any cyclically equivalent list). Is there such a function in Mathematica? Or maybe one can implement it efficiently? Thanks for any suggestion!
list1 === RotateLeft[list2, First @ Position[list2, First @ list1, {1}, 1] - 1]
should be ok. $\endgroup$