I am using v12.2.0 on Win7-x64.

The difference between case 1 and case 2 is that the list being partitioned has 5 elements vs 4 elements, respectively.

Clear["Global*"]
Partition[{a, b, c, d, e}, 3, 1, {3, 1}, {x, y}]


{{x, y, a}, {y, a, b}, {a, b, c}, {b, c, d}, {c, d, e}, {d, e, y}, {e, y, x}}

Partition[{a, b, c, d}, 3, 1, {3, 1}, {x, y}]


{{x, y, a}, {y, a, b}, {a, b, c}, {b, c, d}, {c, d, x}, {d, x, y}}

Question

Why is the cyclic padding different at the tail end of the output list for the two cases? Thank you for your help in advance.

• Similar to 255119 that I just discovered.
– Syed
Commented Apr 1, 2023 at 10:47
• Somewhat similar 50877.
– Syed
Commented Apr 10, 2023 at 12:22

To my understanding Partition constructs an underlying list of repeating sublists of {x,y} which's parts are used to fill in for padding. This I gleaned from this example in the documentation:

https://wolfram.com/xid/0bn6cgi-da1

Let's take an example and mark those positions that will get replaced with "?":

Partition[{a, b,c,d}, 3, 1, {3, 1}, "?"]


{{"?", "?", a}, {"?", a, b}, {a, b, c}, {b, c, d}, {c, d, "?"}, {d, "?", "?"}}

When we construct the corresponding "fill-in"-list with repeating units of {x,y} it will look like this:

Partition[{x, y}, 3, 1, {5, 1}]


{{x, y, x}, {y, x, y}, {x, y, x}, {y, x, y}, {x, y, x}, {y, x, y}}

Putting the "fill in"-list below the desired output of Partition one can easily see where x and y are replacing the corresponding "?":

{{"?", "?", a}, {"?", a, b}, {a, b, c}, {b, c, d}, {c, d, "?"}, {d, "?", "?"}}

{{x, y, x}, {y, x, y}, {x, y, x}, {y, x, y}, {x, y, x}, {y, x, y}}

Which would match your output from above.

The same happens for your other example. Replace {x,y} with "?" and have a look:

Partition[{a, b, c, d, e}, 3, 1, {3, 1}, "?"]


{{"?", "?", a}, {"?", a, b}, {a, b, c}, {b, c, d}, {c, d, e}, {d, e, "?"}, {e, "?", "?"}}

Compare it with the corresponding "fill-in"-list:

{{"?", "?", a}, {"?", a, b}, {a, b, c}, {b, c, d}, {c, d, e}, {d, e, "?"}, {e, "?", "?"}}

{{x, y, x}, {y, x, y}, {x, y, x}, {y, x, y}, {x, y, x}, {y, x, y},{x, y, x}}

Here you can see that the parts of the "fill-in"-list are y and y,x for filling the last two sublists in your example.

• Thanks for your answer. I appreciate it very much. I can't phrase my lack of understanding clearly yet but roughly: Does the padlist always start at the first element such as x and then the padlist is repeated to create the fill-in list, no matter what the location kL is? Please allow me to study and experiment with it further.
– Syed
Commented Mar 28, 2023 at 18:30
• @Syed You can check out the tutorial on Partition` here: reference.wolfram.com/language/tutorial/… While I do believe to understand why the padding at the end of the list looks the way it does, I do not yet quite grasp why the beginning is doing what it's doing. I'd need to experiment myself and wrap my head around this. Commented Mar 29, 2023 at 7:11