16 lines
354 B
Text
16 lines
354 B
Text
// https://rosettacode.org/wiki/Repeat_a_string
|
|
import ballerina/io;
|
|
|
|
function repeat(int l, string s) returns string {
|
|
string[] out = [];
|
|
foreach int _ in 1...l {
|
|
out.push(s);
|
|
}
|
|
return "".concat(...out);
|
|
}
|
|
|
|
public function main() {
|
|
io:println(repeat(5, "ha"));
|
|
// Repeat a character:
|
|
io:println("".padEnd(5, "x"));
|
|
}
|