:: (a -> Bool) -> ([a] -> Bool) -package:fixed-vector

Applied to a predicate and a list, any determines if any element of the list satisfies the predicate. For the result to be False, the list must be finite; True, however, results from a True value for the predicate applied to an element at a finite index of a finite or infinite list.

Examples

>>> any (> 3) []
False
>>> any (> 3) [1,2]
False
>>> any (> 3) [1,2,3,4,5]
True
>>> any (> 3) [1..]
True
>>> any (> 3) [0, -1..]
* Hangs forever *
Applied to a predicate and a list, all determines if all elements of the list satisfy the predicate. For the result to be True, the list must be finite; False, however, results from a False value for the predicate applied to an element at a finite index of a finite or infinite list.

Examples

>>> all (> 3) []
True
>>> all (> 3) [1,2]
False
>>> all (> 3) [1,2,3,4,5]
False
>>> all (> 3) [1..]
False
>>> all (> 3) [4..]
* Hangs forever *
Version of all that fails on an empty list.
Determines whether no element of the given list satisfies the predicate.
> none even [3,5,7,11,13]
True
> none even [7,5,3,2]
False
Determines whether any element of the structure satisfies the predicate.

Examples

Basic usage:
>>> any (> 3) []
False
>>> any (> 3) [1,2]
False
>>> any (> 3) [1,2,3,4,5]
True
>>> any (> 3) [1..]
True
>>> any (> 3) [0, -1..]
* Hangs forever *
Determines whether all elements of the structure satisfy the predicate.

Examples

Basic usage:
>>> all (> 3) []
True
>>> all (> 3) [1,2]
False
>>> all (> 3) [1,2,3,4,5]
False
>>> all (> 3) [1..]
False
>>> all (> 3) [4..]
* Hangs forever *
Determines whether all elements of the structure satisfy the predicate.
Determines whether any element of the structure satisfies the predicate.
O(n) Check if all elements satisfy the predicate.

Examples

>>> import qualified Data.Vector.Strict as V

>>> V.all even $ V.fromList [2, 4, 12]
True

>>> V.all even $ V.fromList [2, 4, 13]
False

>>> V.all even (V.empty :: V.Vector Int)
True
O(n) Check if any element satisfies the predicate.

Examples

>>> import qualified Data.Vector.Strict as V

>>> V.any even $ V.fromList [1, 3, 7]
False

>>> V.any even $ V.fromList [3, 2, 13]
True

>>> V.any even (V.empty :: V.Vector Int)
False
Determines whether no elements of the structure satisfy the predicate.
none f ≡ not . any f