an input range with a length, or a forward range
element to pad the range with
the length to pad to
A range containing the elements of the original range with the extra padding
See Also: std.string.leftJustifier
import std.algorithm.comparison : equal; assert([1, 2, 3, 4].padLeft(0, 6).equal([0, 0, 1, 2, 3, 4])); assert([1, 2, 3, 4].padLeft(0, 3).equal([1, 2, 3, 4])); assert("abc".padLeft('_', 6).equal("___abc"));
Extends the length of the input range r by padding out the start of the range with the element e. The element e must be of a common type with the element type of the range r as defined by std.traits.CommonType. If n is less than the length of of r, then r is returned unmodified.
If r is a string with Unicode characters in it, padLeft follows D's rules about length for strings, which is not the number of characters, or graphemes, but instead the number of encoding units. If you want to treat each grapheme as only one encoding unit long, then call std.uni.byGrapheme before calling this function.
If r has a length, then this is O(1). Otherwise, it's O(r.length).