summaryrefslogtreecommitdiff
path: root/src/pkg/strings/strings.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/strings/strings.go')
-rw-r--r--src/pkg/strings/strings.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go
index 055d7d1e9..7ccfc5ca8 100644
--- a/src/pkg/strings/strings.go
+++ b/src/pkg/strings/strings.go
@@ -188,6 +188,20 @@ func Map(mapping func(rune int) int, s string) string {
return string(b[0:nbytes]);
}
+// Repeat returns a new string consisting of count copies of the string s.
+func Repeat(s string, count int) string {
+ b := make([]byte, len(s)*count);
+ bp := 0;
+ for i := 0; i < count; i++ {
+ for j := 0; j < len(s); j++ {
+ b[bp] = s[j];
+ bp++;
+ }
+ }
+ return string(b);
+}
+
+
// ToUpper returns a copy of the string s with all Unicode letters mapped to their upper case.
func ToUpper(s string) string { return Map(unicode.ToUpper, s) }