package core // Partition splits xs into two slices: the first contains elements where pred returns true, // the second contains elements where pred returns false. Original order is preserved in both. func Partition[T any](xs []T, pred func(T) bool) ([]T, []T) { trueSlice := make([]T, 0) falseSlice := make([]T, 0) for _, x := range xs { if pred(x) { trueSlice = append(trueSlice, x) } else { falseSlice = append(falseSlice, x) } } return trueSlice, falseSlice }