package list func Map[V any, T any](source []V, fun func(V) T) []T { result := make([]T, 0, len(source)) for _, s := range source { result = append(result, fun(s)) } return result } type Pair[T, U any] struct { Left T Right U } func Zip[T, U any](left []T, right []U) []Pair[T, U] { // pick the array with the smaller length l := len(left) if len(left) > len(right) { l = len(right) } pairs := make([]Pair[T, U], len(left)) for i := 0; i < l; i++ { pairs[i] = Pair[T, U]{left[i], right[i]} } return pairs } func Revert[T any](s []T) { for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } }