This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

PadLeft

PadLeft
makes a list of length n by padding list with zeros on the left.
PadLeft
pads by repeating the element x.
PadLeft
pads by cyclically repeating the elements .
PadLeft
leaves a margin of m elements of padding on the right.
PadLeft
makes a nested list with length at level i.
PadLeft[list]
pads a ragged array list with zeros to make it full.
  • PadLeft always returns a list of length n, except in some special cases where padding is .
  • With padding cyclic repetitions of the are effectively laid down and then the list is superimposed on top of them, with the last element of the list lying on an occurrence of . »
  • PadLeft truncates the last m elements of list.
  • A margin of Round[(n-Length[list])/2] effectively centers list.
  • PadLeft effectively treats list as cyclic.
  • PadLeft can be used to repeat an individual element that is itself a list.
  • PadLeft repeats the sequence of as many times as fits in a list of length n.
  • PadLeft creates a full array with dimensions even if list is ragged. »
  • Negative specify to pad on the right.
  • PadLeft pads by repeating the block of .
  • PadLeft effectively treats list as cyclic in every dimension.
  • The object list need not have head List.
Pad with to make the list be of length 10:
Pad with :
Pad by repeating :
Leave margin 2 on the right:
Pad to make a array:
Pad to make a full array:
Pad with to make the list be of length 10:
In[1]:=
Click for copyable input
Out[1]=
 
Pad with :
In[1]:=
Click for copyable input
Out[1]=
 
Pad by repeating :
In[1]:=
Click for copyable input
Out[1]=
 
Leave margin 2 on the right:
In[1]:=
Click for copyable input
Out[1]=
 
Pad to make a array:
In[1]:=
Click for copyable input
Out[1]//TableForm=
 
Pad to make a full array:
In[1]:=
Click for copyable input
Out[1]//TableForm=
Negative length specifications pad on the right:
Lay down repetitions of the padding, then superimpose the original array:
Use different margins for rows and columns:
Use a head other than List:
Put a 1 at the center of a list of 0s:
Pad digit lists to be the same length:
Lay out an array of tiles:
PadLeft and PadRight pad to make a list of length n:
ArrayPad pads with n additional elements on each side:
Pad with an element that is itself a list:
New in 4 | Last modified in 6