Better paragraph splitting

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto
2025-03-25 22:28:08 +01:00
parent 54c8bf5f1a
commit fa12dba7c2
6 changed files with 186 additions and 52 deletions

15
pkg/xstrings/uniq.go Normal file
View File

@@ -0,0 +1,15 @@
package xstrings
type Comparable interface{ ~int | ~int64 | ~string }
func UniqueSlice[T Comparable](s []T) []T {
keys := make(map[T]bool)
list := []T{}
for _, entry := range s {
if _, value := keys[entry]; !value {
keys[entry] = true
list = append(list, entry)
}
}
return list
}