2020-11-26 04:18:52 +00:00
|
|
|
package main
|
|
|
|
|
2020-11-30 23:27:29 +00:00
|
|
|
import "fmt"
|
|
|
|
|
2020-11-26 04:18:52 +00:00
|
|
|
// Remove an element at an index from a slice
|
|
|
|
func removeAtIndex(s []string, index int) []string {
|
|
|
|
return append(s[:index], s[index+1:]...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if slice contains string
|
|
|
|
func Contains(slice []string, val string) bool {
|
|
|
|
for _, item := range slice {
|
|
|
|
if item == val {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func Max(array []float64) float64 {
|
|
|
|
var max = array[0]
|
|
|
|
var min = array[0]
|
|
|
|
for _, value := range array {
|
|
|
|
if max < value {
|
|
|
|
max = value
|
|
|
|
}
|
|
|
|
if min > value {
|
|
|
|
min = value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return max
|
|
|
|
}
|
|
|
|
|
|
|
|
func Find(slice []string, val string) int {
|
|
|
|
for i, item := range slice {
|
|
|
|
if item == val {
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1
|
2020-11-30 23:27:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func InterfaceToString(interfaceSlice []interface{}) []string {
|
|
|
|
returnedSlice := make([]string, len(interfaceSlice))
|
|
|
|
for index, element := range interfaceSlice {
|
|
|
|
returnedSlice[index] = fmt.Sprint(element)
|
|
|
|
}
|
|
|
|
return returnedSlice
|
2020-11-26 04:18:52 +00:00
|
|
|
}
|