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

  1. package main
  2. import (
  3. "strings"
  4. )
  5. func getLines(text string) []string {
  6. lines := strings.Split(text, "\n")
  7. return lines
  8. }
  9. func concatStringsWithJumps(lines []string) string {
  10. var r string
  11. for _, l := range lines {
  12. r = r + l + "\n"
  13. }
  14. return r
  15. }
  16. func locateStringInArray(lines []string, s string) []int {
  17. var positions []int
  18. for k, l := range lines {
  19. if strings.Contains(l, s) {
  20. positions = append(positions, k)
  21. }
  22. }
  23. return positions
  24. }
  25. func deleteArrayElementsWithString(lines []string, s string) []string {
  26. var result []string
  27. for _, l := range lines {
  28. if !strings.Contains(l, s) {
  29. result = append(result, l)
  30. }
  31. }
  32. return result
  33. }
  34. func deleteLinesBetween(lines []string, from int, to int) []string {
  35. var result []string
  36. result = append(lines[:from], lines[to+1:]...)
  37. return result
  38. }
  39. func addElementsToArrayPosition(lines []string, newLines []string, pos int) []string {
  40. var result []string
  41. result = append(result, lines[:pos]...)
  42. result = append(result, newLines...)
  43. result = append(result, lines[pos:]...)
  44. /*
  45. result = append(lines[:pos], newLines...)
  46. result = append(result, lines[pos:]...)
  47. */
  48. return result
  49. }