After 20 years of Mathematica I must confess to having no clue about anything involving permutations, cycles or groups. I would like to find some information in English, because documentation assumes too much background for a high school grad like me. For example, playing with toy NK landscape models, I can construct a k=1 list of four elements as follows, but it seems crude.
With[{x = {1, 2, 3, 4}}, Union[Partition[x, 2, 1], {{x[[Length@x]], x[[1]]}}]] (* for k>1, this could become messy *)
I assume such cyclic patterns would be used quite often in discrete applications. How do knowledgable people accomplish such things?
Wow, that was simple... never thought about padding right or left. Thanks a lot! I just figured out how to treat other neighborhood sizes: With[{r = Range@5, n = 4}, Partition[PadRight[r, Length@r + n - 1, r], n, 1]] Any idea about introductory texts? I had all of Trott's books out could never follow two consecutive pages. Guess I need the groups for dummies book.
Using Join and Take
Join
Take
With[{r = Range@5, n = 4}, Partition[Join[r, Take[r, n - 1]], n, 1]] (* {{1, 2, 3, 4}, {2, 3, 4, 5}, {3, 4, 5, 1}, {4, 5, 1, 2}, {5, 1, 2, 3}} *)
This is one way:
r = Range@5 Partition[PadRight[r, Length@r + 1, First@r], 2, 1] (* {{1,2},{2,3},{3,4},{4,5},{5,1}} *)