MathGroup Archive 2010

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

Search the Archive

Re: Bug in PadLeft/PadRight

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109311] Re: Bug in PadLeft/PadRight
  • From: Rui <rui.rojo at gmail.com>
  • Date: Wed, 21 Apr 2010 04:32:03 -0400 (EDT)
  • References: <hpkgkn$817$1@smc.vnet.net>

On Apr 8, 9:02 am, dh <d... at metrohm.com> 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
> --
>
> Daniel Huber
> Metrohm Ltd.
> Oberdorfstr. 68
> CH-9100 Herisau
> Tel. +41 71 353 8585, Fax +41 71 353 8907
> E-Mail:<mailto:d... at metrohm.com>
> Internet:<http://www.metrohm.com>

They are just not documented to work as you expect them to. PadLeft
and PadRight both.
in both, first you have to cyclically repeat the padding list as if it
was the background and then, "on top" of that, put your list. In the
case of PadLeft, the last element of your list always goes on top of
the last element of the padding list. In PadRight, first with first.
It's there in More Infromation in the documentation


  • Prev by Date: Re: Finding the extreme function values.
  • Next by Date: Re: Finding the extreme function values.
  • Previous by thread: Re: Bug in PadLeft/PadRight
  • Next by thread: Branching on error messages?