You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

58 lines
1.1 KiB

package main
import (
"strings"
)
func getLines(text string) []string {
lines := strings.Split(text, "\n")
return lines
}
func concatStringsWithJumps(lines []string) string {
var r string
for _, l := range lines {
r = r + l + "\n"
}
return r
}
func locateStringInArray(lines []string, s string) []int {
var positions []int
for k, l := range lines {
if strings.Contains(l, s) {
positions = append(positions, k)
}
}
return positions
}
func deleteArrayElementsWithString(lines []string, s string) []string {
var result []string
for _, l := range lines {
if !strings.Contains(l, s) {
result = append(result, l)
}
}
return result
}
func deleteLinesBetween(lines []string, from int, to int) []string {
var result []string
result = append(lines[:from], lines[to+1:]...)
return result
}
func addElementsToArrayPosition(lines []string, newLines []string, pos int) []string {
var result []string
result = append(result, lines[:pos]...)
result = append(result, newLines...)
result = append(result, lines[pos:]...)
/*
result = append(lines[:pos], newLines...)
result = append(result, lines[pos:]...)
*/
return result
}