Qu

pad_right

Builtin index · Collections & strings

result = pad_right(s, width, [fill=" "])

Input: s, width, fill · Output: result

What it is

Same parameters and return as pad_left, padding on the right instead.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = pad_right(s, width, [fill=" "])
s StrReturns a Str of at least width characters — s unchanged when it is already that long.
width StrReturns a Str of at least width characters — s unchanged when it is already that long.
fill optional (default " ")not documented yet
result Str
Returns a Str of at least width characters — s unchanged when it is already that long.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

s = "Hello, Qu World!"
print(mid(s, 7, 2))          # "Qu"

print(left(s, 5))            # "Hello"

print(right(s, 6))           # "World!"

print(reverse("abc"))        # "cba"

print(lower("SHOUT"))        # "shout"

print(ucase("shout"))        # "SHOUT"

print(lcase("SHOUT"))        # "shout"

print(toupper("mix"))        # "MIX"

print(tolower("MIX"))        # "mix"

print(capitalize("ada lovelace"))  # "Ada lovelace"

print(ltrim("   padded"))    # "padded"

print(rtrim("padded   ") + "|")   # "padded|"

print(pad_right("ab", 5, "."))    # "ab..."

print(compare("apple", "banana")) # -1

print(asc("A"))              # 65

output
Qu
Hello
World!
cba
shout
SHOUT
shout
MIX
mix
Ada lovelace
padded
padded|
ab...
-1
    ... 1 more lines

from collections-strings

How it works

pad_left(s, width, [fill]) / pad_right(...) — pad to a width in CHARACTERS. A string already at or past the width is returned unchanged rather than truncated: padding is for lining columns up, and silently losing text to make a column fit is never what was meant.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.