PadLeft¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
PadLeft[list, n]
makes a list of length n by padding list with zeros on the left.
PadLeft[list, n, x]
pads by repeating the element x.
PadLeft[list, n, {x1, x2, ...}]
pads by cyclically repeating the elements xi.
PadLeft[list, n, padding, m]
leaves a margin of m elements of padding on the right.
PadLeft[list, {n1, n2, ...}]
makes a nested list with length ni at level i.
PadLeft[list]
pads a ragged array list with zeros to make it full.
Notes
A negative length pads on the right; a negative margin truncates trailing elements. The head of list need not be List.Examples (2)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (2)¶
In[1]:= PadLeft[{a, b, c}, 10, {x, y, z}]
Out[1]= {z, x, y, z, x, y, z, a, b, c}
In[2]:= PadRight[{{a, b}, {c}}, {3, 5}]
Out[2]= {{a, b, 0, 0, 0}, {c, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}
Implementation notes¶
Attributes: Protected.
References¶
- Source:
src/info.c - Specification:
docs/spec/builtins/structural-manipulation.md - Tests:
tests/test_padleft.c