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

Documentation / Mathematica / Built-in Functions / Lists and Matrices / List Operations /

PadLeft

FilledSmallSquare PadLeft[list, n] makes a list of length n by padding list with zeros on the left.

FilledSmallSquare PadLeft[list, n, x] pads by repeating the element x.

FilledSmallSquare PadLeft[list, n, , , ... ] pads by cyclically repeating the elements .

FilledSmallSquare PadLeft[list, n, padding, m] leaves a margin of m elements of padding on the right.

FilledSmallSquare PadLeft[list, , , ... ] makes a nested list with length at level i.

FilledSmallSquare Example: PadLeft[a,b,c, 7] LongRightArrow.

FilledSmallSquare PadLeft[list, n, ... ] always returns a list of length n, except in some special cases where padding is {}.

FilledSmallSquare 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 .

FilledSmallSquare Examples: PadLeft[a,b, 7, x,y,z] LongRightArrow.

FilledSmallSquare PadLeft[a,b, 7, x,y,z, 2] LongRightArrow.

FilledSmallSquare PadLeft[list, n, padding, -m] truncates the last m elements of list.

FilledSmallSquare A margin of Round[(n-Length[list])/2] effectively centers list.

FilledSmallSquare PadLeft[list, n, list] effectively treats list as cyclic.

FilledSmallSquare PadLeft[list, n, xlist] can be used to repeat an individual element that is itself a list.

FilledSmallSquare Example: PadLeft[a,b,c, 5, u] LongRightArrow.

FilledSmallSquare PadLeft[, n, , , ... ] repeats the sequence of as many times as fits in a list of length n.

FilledSmallSquare PadLeft[list, , , ... ] creates a full array with dimensions , , ... even if list is ragged.

FilledSmallSquare Negative specify to pad on the right.

FilledSmallSquare PadLeft[list, , , , , ... , , ... , ... ] pads by repeating the block of .

FilledSmallSquare PadLeft[list, , , ... , list] effectively treats list as cyclic in every dimension.

FilledSmallSquare PadLeft[list, , , ... , padding, , , ... ] uses margin at level i.

FilledSmallSquare The object list need not have head List.

FilledSmallSquare PadLeft can be used on SparseArray objects.

FilledSmallSquare See Section 1.8.9, Section 2.4.3 and Section 2.4.4.

FilledSmallSquare See also: PadRight, Join, Partition, ListCorrelate, RotateLeft.

FilledSmallSquare New in Version 4.

Further Examples