aboutsummaryrefslogtreecommitdiff
path: root/go-src/utils.go
blob: 5d60ee98fd7261525b3b7235848c15d6640ecd59 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package main

// Repeats a rune given amount of times and returns the result as a string
func repeatRune(r rune, times int) (result string) {
	for i := 0; i < times; i++ {
		result += string(r)
	}
	return
}

// Replaces a character inside a string with a given rune at index
//
// Thanks https://stackoverflow.com/a/24894202/12036073
func replaceAtIndex(in string, r rune, i int) string {
	out := []rune(in)
	out[i] = r
	return string(out)
}