import { curry, Predicate } from '@typed/lambda'
/**
* Returns true if any values in a list pass the given predicate.
* @param predicate :: (a -> boolean)
* @param list :: [a]
* @returns :: boolean
*/
// tslint:disable-next-line:variable-name
export const any: {
(predicate: Predicate, list: readonly A[]): boolean
(predicate: Predicate): (list: readonly A[]) => boolean
} = curry(__any) as {
(predicate: Predicate, list: readonly A[]): boolean
(predicate: Predicate): (list: readonly A[]) => boolean
}
function __any(predicate: Predicate, list: readonly A[]): boolean {
for (const value of list) {
if (predicate(value)) {
return true
}
}
return false
}