package core

// MapSlice applies fn to each element of xs and returns a new slice with the results.
// Does not mutate the original slice.
func MapSlice[T any, U any](xs []T, fn func(T) U) []U {
	result := make([]U, len(xs))
	for i, x := range xs {
		result[i] = fn(x)
	}
	return result
}
