Group Abstract Group Abstract

Message Boards Message Boards

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

Reading materials needed about permutations?

Posted 6 years ago
POSTED BY: David Barnes
3 Replies
Posted 6 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 6 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 6 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