diff --git a/misc.go b/misc.go index cf56708..8f4f904 100644 --- a/misc.go +++ b/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 +}