Added function allEqual - checks if all given values are equal
This commit is contained in:
11
misc.go
11
misc.go
@@ -27,3 +27,14 @@ func unique_append[T comparable](slc []T, items ...T) ([]T, int) {
|
||||
}
|
||||
return slc, num_appended
|
||||
}
|
||||
|
||||
// Returns true only if all the given elements are equal
|
||||
func allEqual[T comparable](items ...T) bool {
|
||||
first := items[0]
|
||||
for _, item := range items {
|
||||
if item != first {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user