package gentools func IndexOf[T comparable](arr []T, value T) int { for i, v := range arr { if v == value { return i } } return -1 } func AddUniques[T comparable](arr *[]T, values ...T) { Outer: for _, v := range values { for _, v2 := range *arr { if v2 == v { continue Outer } } *arr = append(*arr, v) } } func Map[T any, U any](arr []T, cb func(T) U) []U { arr2 := make([]U, len(arr)) for i, v := range arr { arr2[i] = cb(v) } return arr2 } func Flatten[T any](arr [][]T) []T { arr2 := make([]T, 0, 128) for _, sub := range arr { arr2 = sub } return arr2 }