package core

// FilterSlice returns a new slice containing only elements where pred returns true.
// Does not mutate the original slice.
func FilterSlice[T any](xs []T, pred func(T) bool) []T {
	result := make([]T, 0, len(xs))
	for _, x := range xs {
		if pred(x) {
			result = append(result, x)
		}
	}
	return result
}
