diff options
| author | ayyansea <ayyansea@gmail.com> | 2024-11-27 23:28:05 +0300 |
|---|---|---|
| committer | ayyansea <ayyansea@gmail.com> | 2024-11-27 23:28:05 +0300 |
| commit | d0b5612d38595e8147aa9c75cbb5bb2c3fc81bbe (patch) | |
| tree | f8d7dc049559b52ba33adb929a8b83f3740b082f /internal/split/split.go | |
| parent | 1a1411acb16b53d08ed8088d7fd3fabbb253a4e8 (diff) | |
feat: revamped program logic and removed unnecessary methods and modules
Diffstat (limited to 'internal/split/split.go')
| -rw-r--r-- | internal/split/split.go | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/internal/split/split.go b/internal/split/split.go deleted file mode 100644 index e03335c..0000000 --- a/internal/split/split.go +++ /dev/null @@ -1,55 +0,0 @@ -package split - -import ( - "strings" -) - -func FormatInput(tokenArray []string, delimeterArray []string) []string { - for _, delimeter := range delimeterArray { - for index, element := range tokenArray { - tokenArray = NewArrayWithSplit(tokenArray, index, element, delimeter) - } - } - - return tokenArray -} - -func checkArrayElementsEmpty(array []string) bool { - for _, str := range array { - if str != "" { - return false - } - } - return true -} - -func NewArrayWithSplit(initialArray []string, index int, token string, delimeter string) (result []string) { - split := strings.Split(token, delimeter) - splitLength := len(split) - - /* - When a token only consists of delimeter * N (N >= 0), - the resulting split consists of N empty elements. - Here we check if it is so and essentialy remove that token - from resulting array. - */ - - splitIsEmpty := checkArrayElementsEmpty(split) - if splitIsEmpty { - result = append(initialArray[:index], initialArray[index+1:]...) - return result - } - - if splitLength > 1 { - if split[splitLength-1] == "" { - split = split[:splitLength-1] - } - - result = append(initialArray[:index], append(split, initialArray[index+1:]...)...) - } - if splitLength == 1 { - result = initialArray - } - - return result -} |
