Re: Bugs--Bugs Report in List Operation
- To: mathgroup at smc.vnet.net
- Subject: [mg67559] Re: [mg67519] Bugs--Bugs Report in List Operation
- From: Bruce Miller <brucem at wolfram.com>
- Date: Fri, 30 Jun 2006 04:15:34 -0400 (EDT)
- References: <200606290409.AAA29037@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Xiao, The documentation is not as clear as it could be in this case. In the function documentation, the third bullet under PadRight, * PadRight[list, n, {a, a, ? }] pads by cyclically repeating the elements a. The behavior you found happens because the Head of a non-atomic third argument need not be List. In these cases, the arguments of the function call are used for padding. In your example, 1s are padded because Infinity is internally DirectedInfinity[1]. For another example, try an undefined function f. In[1]:= PadRight[{0}, 5, Infinity] Out[1]= {0, 1, 1, 1, 1} In[2]:= PadRight[{0}, 3, f[x]] Out[2]= {0, x, x} In[3]:= PadRight[{0}, 3, f[x,y]] Out[13]= {0, y, x} To get what you are expecting, you can replace Infinity with {Infinity}. In[4]:= PadRight[{0}, 5,{Infinity}] Out[4]= {0, Infinity, Infinity, Infinity, Infinity} A request for clarification of this was filed with the documentation staff. Bruce Miller Technical Support Wolfram Research, Inc. support at wolfram.com http://support.wolfram.com/ On Jun 28, 2006, at 11:09 PM, xiao.k.li at gmail.com wrote: > I have discovered a bug in both PadLeft[] and PadRight[].<br> > Bellow is the test.<br> > As the test shows, in PadRight[], Mathematica 5.2 replaced Infinity as > 1 automatically, which is not supposed to happen.<br> > <br> > In[1]:= img = Table[x*10 + y, {x, 3}, {y, 3}] > > Out[1]:= {{11, 12, 13}, {21, 22, 23}, {31, 32, 33}} > > ----------------------------------------- > > In[2]:= PadRight[img, {3, 3}, value, {1, 1}] > > Out[2]:= {{value, value, value}, {value, 11, 12}, {value, 21, 22}} > > ----------------------------------------- > > In[3]:= PadRight[img, {3, 3}, Infinity, {1, 1}] > > Out[3]:= {{1, 1, 1}, {1, 11, 12}, {1, 21, 22}} > > ----------------------------------------- > > And as far as I know, these functions are fine while dealing with > other values such as number, symbol and string. > > I hope above information will be a little helpful if others come cross > the case in future. > > Link to the forum page for this post: > http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp? > pageName=Special:Forum_ViewTopic&pid=11463#p11463 > Posted through http://www.mathematica-users.org [[postId=11463]] >
- References:
- Bugs--Bugs Report in List Operation
- From: xiao.k.li@gmail.com
- Bugs--Bugs Report in List Operation