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.