Adds a function to test that a list contains at least one occurrence of an element

This commit is contained in:
2022-08-23 11:06:28 +02:00
parent 5a81525e46
commit 1e58c92086

View File

@ -160,3 +160,13 @@ func ReadLines(path string) (lines []string, err error) {
} }
return return
} }
func Contains[T comparable](arr []T, x T) bool {
for _, v := range arr {
if v == x {
return true
}
}
return false
}