Skip to content

StringRepeat

Repeats a string n times.

$ wo 'StringRepeat["ab", 3]'
ababab
$ wo 'StringRepeat["x", 5]'
xxxxx
$ wo 'StringRepeat["hello", 0]'

Zero repetitions give the empty string, and a negative count is reported:

$ wo 'StringRepeat["abcde", 0] === ""'
True
$ wo 'StringRepeat["abcde", -1]'

StringRepeat::intp: Positive integer expected at position 2 in StringRepeat[abcde, -1].
StringRepeat[abcde, -1]

The third argument truncates, and is checked the same way:

$ wo 'StringRepeat["abcde", 3, 7]'
abcdeab
$ wo 'StringRepeat["abcde", 2, -1]'

StringRepeat::intp: Positive integer expected at position 3 in StringRepeat[abcde, 2, -1].
StringRepeat[abcde, 2, -1]