Message Boards Message Boards

0
|
5050 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Reading materials needed about permutations?

Posted 3 years ago

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?

POSTED BY: David Barnes
3 Replies
Posted 3 years ago

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.

POSTED BY: David Barnes
Posted 3 years ago

Using Join and 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}} *)
POSTED BY: Rohit Namjoshi
Posted 3 years ago

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}} *)
POSTED BY: Hans Milton
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract