repeat
fn repeat(string s, int n) -> string Import
Source: use text::{repeat}; src/text.hy Returns s repeated n times; empty when n <= 0.
Parameters#
| Name | Type |
|---|---|
s | string |
n | int |
Returns#
string
Contracts#
Checked according to --contracts (see Contracts).
ensures n > 0 || result == ""
ensures n <= 0 || result.len() == s.len() * n
Examples#
use text::{repeat};
use tests::assert;
assert!(repeat("ab", 3) == "ababab");
See also#
byte_len: Returns the length ofsin bytes; the same ass.len().slice: Returns the part ofsfrom byte offsetstartup to (not including)end.trim_start: Returnsswithout leading ASCII whitespace (space, tab, CR, LF).trim_end: Returnsswithout trailing ASCII whitespace (space, tab, CR, LF).trim: Returnsswithout leading and trailing ASCII whitespace (space, tab, CR, LF).rfind: Returns the byte offset of the lastneedleinhay, or-1.split_at: Splitssat byte offsetatinto the part before and the part fromaton.join: Returns thepartsconcatenated withsepbetween each pair.