:: (a -> Bool) -> ([a] -> Bool) -package:constrained-categories

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 *
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 any element of the structure satisfies the predicate.
Determines whether all elements of the structure satisfy the predicate.
Determines whether no elements of the structure satisfy the predicate.
none f ≡ not . any f
Version on concatMap generalised to a Monoid rather than just a list.
mconcatMap Sum [1,2,3] == Sum 6
\f xs -> mconcatMap f xs == concatMap f xs
A strict version of sum, using a custom valuation function.
sumOn' read ["1", "2", "3"] == 6
A strict version of product, using a custom valuation function.
productOn' read ["1", "2", "4"] == 8