Skip to content

PadLeft

Pads a list on the left to a specified length.

$ wo 'PadLeft[{1, 2, 3}, 5]'
{0, 0, 1, 2, 3}
$ wo 'PadLeft[{a, b}, 4, x]'
{x, x, a, b}
$ wo 'PadLeft[{1, 2, 3, 4, 5}, 3]'
{3, 4, 5}

A padding list is repeated cyclically, aligned to the content:

$ wo 'PadLeft[{1, 2}, 7, {x, y, z}]'
{z, x, y, z, x, 1, 2}

For a nested result the padding array tiles it, level by level:

$ wo 'PadLeft[{{1, 2}, {3, 4}}, {3, 4}, {{a, b}, {c, d}}]'
{{c, d, c, d}, {a, b, 1, 2}, {c, d, 3, 4}}