Re: Bug in PadLeft/PadRight
- To: mathgroup at smc.vnet.net
- Subject: [mg109114] Re: Bug in PadLeft/PadRight
- From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
- Date: Mon, 12 Apr 2010 23:04:31 -0400 (EDT)
- References: <hpkgkn$817$1@smc.vnet.net> <hputql$lhs$1@smc.vnet.net>
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 removedbailey.co.uk> wrote in message news:hputql$lhs$1 at smc.vnet.net... > 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 > http://www.dbaileyconsultancy.co.uk >