Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
s = s.PadLeft(m, c);
s = s.padLeft(m, c);
repeat(x,max(n-len(s),0)) // s
-- BaseString PadChar MinOutputLength PaddedString/Output
padLeft :: String -> Char -> Int -> String
padLeft s c m = let
isBaseLarger = length s > m
padder s c m False = [ c | _ <- [1..(m-length s)]] ++ s
padder s _ _ True = s
in
padder s c m isBaseLarger
s = s.padStart(m, c);
while (s.length() < m) s = c + s;
$s = $c x ($m - length($s)) . $s;
s = s.rjust(m, c)
s = f'{s:{c}>{m}}'
s.rjust(m, c)
if let Some(columns_short) = m.checked_sub(s.width()) {
let padding_width = c
.width()
.filter(|n| *n > 0)
.expect("padding character should be visible");
// Saturate the columns_short
let padding_needed = columns_short + padding_width - 1 / padding_width;
let mut t = String::with_capacity(s.len() + padding_needed);
t.extend((0..padding_needed).map(|_| c)
t.push_str(&s);
s = t;
}