Skip to main content

Vector.pad

padnelem

Group: Calculations

Documentation

Extend self vector to the length of n appending elements elem to the end.

If the new length n is less than existing length, self vector is returned.

Arguments

  • n: The length to pad self out to.
  • elem: The element to fill the new padded slots with.

Examples

Extending vector to the length of 5

      [1, 2, 3].pad 5 0 == [1, 2, 3, 0, 0]

Extending vector to the length of 5

      [1, 2, 3, 4, 5].pad 5 0 == [1, 2, 3, 4, 5]