Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Go
func Contains(list []T, x T) bool {
	for _, item := range list {
		if item == x {
			return true
		}
	}
	return false
}

This func works only for one type T.

You may use any type T compatible with operator ==
import "slices"
slices.Contains(list, x)

This generic func slices.Contains works for all slice types
with Ada.Containers.Vectors;
Result := List.Contains (X);

New implementation...