Added function allEqual - checks if all given values are equal

master
Aadhavan Srinivasan 2 months ago
parent df6efcd1f0
commit cd680371fb

@ -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
}

Loading…
Cancel
Save