/**
* Test if a value is a member of an array. Takes a `Equivalence` as a single
* argument which returns the function to use to search for a value of type `A`
* in an array of type `Chunk`.
*
* @tsplus static Chunk.Aspects elem
* @tsplus pipeable Chunk elem
*/
export function elem(E: Equivalence, value: A) {
return (self: Chunk): boolean => {
const predicate = (element: A) => E.equals(element, value)
for (let i = 0; i < self.length; i++) {
if (predicate(self.unsafeGet(i)!)) {
return true
}
}
return false
}
}