Mathematica 9 is now available

PadLeft

Usage

PadLeft[list, n] 通过在左边对list填充零,构成一个长度为 n的列表。
PadLeft[list, n, x] 通过重复元素 x 填充
PadLeft[list, n,   ,  , ...  ] 通过循环重复元素  填充
PadLeft[list, n, padding, m]留下一个放在右边的m个元素的边距。
PadLeft[list,   ,  , ...  ] 构成在第 i 层的一个长度为  的嵌套列表。


Notes

PadLeft[list, n, ... ] 总是返回一个长度为 n 的列表。
• 例如: PadLeft[ a,b,c , 7]LongRightArrow . • 通过填充   ,  , ... ,   ,有效的规定循环重复  , 然后在它们顶部强加列表,列表的最后一个元素放在  的位置。
• 例如: PadLeft[ a,b , 7,  x,y,z ]LongRightArrow .
PadLeft[ a,b , 7,  x,y,z , 2]LongRightArrow .
PadLeft[list, n, padding, -m]截断list的最后m个元素。
Round[(n-Length[list])/2] 的边距有效的以 list为中心。
PadLeft[list, n, list] 有效的把list处理为循环。
PadLeft[list, n,  xlist ] 可以用于本身是一个列表的个体元素。
• 例如: PadLeft[ a,b,c , 5,   u  ]LongRightArrow .
PadLeft[  , n,   ,  , ...  ] repeats the sequence of  as many times as fits in a list of length n.
PadLeft[  , n,   ,  , ...  ]  序列重复与把它插入长度为n的列表相同的次数.
PadLeft[list,   ,  , ...  ] 创建一个维数为   ,  , ...  的完全数组,即使list被分开
• 负  指定放在右边。
PadLeft[list,   ,   ,    ,  , ...  ,   , ...  , ...  ]通过重复块  填充。
PadLeft[list,   ,  , ...  , list] 在每一维上有效的把list处理为循环。
PadLeft[list,   ,  , ...  , padding ,  ,  , ...  ]在层 i用边距
• 对象list不必有头List
• 参见 Mathematica 全书: 1.8.6.
Further Examples

Padding a list

This makes a list of length  by padding to the left with x's.

In[1]:=  

Out[1]=

Using  gives padding on the right.

In[2]:=  

Out[2]=

Using an empty list you can see how a cyclic padding ends on the last element of the padding.

In[3]:=  

Out[3]=

Now the nonempty list is superimposed on the padding.

In[4]:=  

Out[4]=

Here the list is padded on the right by  elements.

In[5]:=  

Out[5]=

And here the last  elements of the list are dropped.

In[6]:=  

Out[6]=

This treats the list as cyclic.

In[7]:=  

Out[7]=

This has the same effect.

In[8]:=  

Out[8]=

Padding a matrix

This pads a  x  matrix to give  rows and  columns.

In[9]:=  

Out[9]//MatrixForm=

This does the same thing, but uses a  x  block to provide the padding.

In[10]:=  

Out[10]//MatrixForm=

This shifts the matrix up  row and to the left  columns.

In[11]:=  

Out[11]//MatrixForm=

Padding graphics

Here is a nested list.

In[12]:=  

Out[12]//MatrixForm=

This represents the list using Raster. (Raster starts from the lower-left corner so the picture seems upside-down.)

Evaluate the cell to see the graphic.

In[13]:=  

Here the list is padded.

In[14]:=  

Out[14]//MatrixForm=

Evaluate the cell to see the graphic.

In[15]:=  

Here are two different paddings.

In[16]:=  

Out[16]//MatrixForm=

Evaluate the cell to see the graphic.

In[17]:=  

In[18]:=  

Out[18]//MatrixForm=

Evaluate the cell to see the graphic.

In[19]:=  



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.