Better paragraph splitting
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
15
pkg/xstrings/uniq.go
Normal file
15
pkg/xstrings/uniq.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user