Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bug in PadLeft/PadRight

  • To: mathgroup at
  • Subject: [mg109114] Re: Bug in PadLeft/PadRight
  • From: "Steve Luttrell" <steve at>
  • Date: Mon, 12 Apr 2010 23:04:31 -0400 (EDT)
  • References: <hpkgkn$817$> <hputql$lhs$>

In the documentation for PadRight it says:

"With padding {Subscript[x, 1],Subscript[x, 2],\[Ellipsis],Subscript[x, s]} 
cyclic repetitions of the Subscript[x, i] are effectively laid down and then 
the list is superimposed on top of them, with the first element of the list 
lying on an occurrence of Subscript[x, 1]."

That means your example PadRight[{y4, x1, x2, x3, x4}, 6, {y1, y2, y3, y4}] 
works correctly.

Stephen Luttrell
West Malvern, UK

"David Bailey" <dave at> wrote in message 
news:hputql$lhs$1 at
> dh wrote:
>> Hello,
>> hope I am not fooling myself, but there seems to be a problem with
>> padding. PadLeft/PadRight seem to work as expected when used alone.
>> However if we use them sequentially there seems to be some unwanted 
>> effects.
>> Consider:
>> npad = 1;
>> d = d0 = {x1, x2, x3, x4};
>> d = PadLeft[d, npad + Length[d], d0]
>> d = PadRight[d, npad + Length[d], d0]
>> For npad=1 padding on the right does not start with the first element of
>> d0, but with the second one.
>> For npad=2, padding starts with the third element, e.t.c.
>> If we eliminate the PadLeft, PadRight works as expected.
>> cheers, Daniel
> Well, I also get the wrong answer (using a fresh kernel) for:
> In[1]:= PadRight[{y4, x1, x2, x3, x4}, 6, {y1, y2, y3, y4}]
> Out[1]= {y4, x1, x2, x3, x4, y2}
> I guess you should send that to support.
> David Bailey

  • Prev by Date: Re: beginner question about syntax
  • Next by Date: Using package functions in Manipulate/DynamicModule
  • Previous by thread: Re: Bug in PadLeft/PadRight
  • Next by thread: Re: Bug in PadLeft/PadRight