fn: add Elem function for set membership

This commit is contained in:
Keagan McClelland committed 2024-07-10 15:37:27 -07:00
1 parent 9c30bce10c
commit fb1437cb6d
1 file changed
+5
+5
View File
@@ -114,6 +114,11 @@ func FindIdx[A any](pred Pred[A], s []A) Option[T2[int, A]] {
return None[T2[int, A]]()
}
// Elem returns true if the element in the argument is found in the slice
func Elem[A comparable](a A, s []A) bool {
return Any(Eq(a), s)
}
// Flatten takes a slice of slices and returns a concatenation of those slices.
func Flatten[A any](s [][]A) []A {
sz := Foldr(