Wolfram Research

Function Repository Resource:

CanonicalListRotation (1.1.0) current version: 1.1.1 »

Source Notebook

Return a canonical rotation for a list of values

Contributed by: Ed Pegg Jr

ResourceFunction["CanonicalListRotation"][list]

sorts list, keeping rotationally-neighboring terms as neighbors.

ResourceFunction["CanonicalListRotation"][list,False]

excludes reversals and cyclic permutations thereof.

Examples

Basic Examples (2) 

The list of items is returned as the lexicographically-first rotation:

In[1]:=
ResourceFunction["CanonicalListRotation", ResourceVersion->"1.1.0"][{4, 7, 20, 10, 9, 18, 5, 1, 14, 12}]
Out[1]=

Exclude reversals and cyclic permutations of reversals:

In[2]:=
ResourceFunction["CanonicalListRotation", ResourceVersion->"1.1.0"][{4, 7, 20, 10, 9, 18, 5, 1, 14, 12}, False]
Out[2]=

Applications (1) 

Generate the six faces of a cube:

In[3]:=
face = {{1, -1, -1}, {1, -1, 1}, {1, 1, 1}, {1, 1, -1}};
Union[ResourceFunction["CanonicalListRotation"][face . #] & /@ FiniteGroupData["Octahedral", "MatrixRepresentation"]]
Out[3]=
In[4]:=
Graphics3D[Polygon[%]]
Out[4]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.1.1 – 13 September 2024
  • 1.1.0 – 21 September 2021
  • 1.0.0 – 06 February 2019

License Information