any -package:relude

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 *
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.
>>> 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 *
O(n) Applied to a predicate and a ByteString, any determines if any element of the ByteString satisfies the predicate.
Applied to a predicate and a ByteString, any determines if any element of the ByteString satisfies the predicate.
O(n) Applied to a predicate and a ShortByteString, any determines if any element of the ShortByteString satisfies the predicate.
O(n) any p t determines whether any character in the Text t satisfies the predicate p.
O(n) any p xs determines if any character in the stream xs satisfies the predicate p. Properties
any f . stream = any f
O(n) Applied to a predicate and a ByteString, any determines if any element of the ByteString satisfies the predicate.
O(n) Applied to a predicate and a ByteString, any determines if any element of the ByteString satisfies the predicate.
O(n) Check if any element satisfies the predicate.

Examples

>>> import qualified Data.Vector 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
O(n) Check if any element satisfies the predicate.

Examples

>>> import qualified Data.Vector 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
O(n) Check if any element satisfies the predicate.

Examples

>>> import qualified Data.Vector.Primitive as VP

>>> VP.any even $ VP.fromList [1, 3, 7 :: Int]
False

>>> VP.any even $ VP.fromList [3, 2, 13 :: Int]
True

>>> VP.any even (VP.empty :: VP.Vector Int)
False
O(n) Check if any element satisfies the predicate.

Examples

>>> import qualified Data.Vector.Storable as VS

>>> VS.any even $ VS.fromList [1, 3, 7 :: Int]
False

>>> VS.any even $ VS.fromList [3, 2, 13 :: Int]
True

>>> VS.any even (VS.empty :: VS.Vector Int)
False
O(n) Check if any element satisfies the predicate.

Examples

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.any even $ VU.fromList [1, 3, 7 :: Int]
False

>>> VU.any even $ VU.fromList [3, 2, 13 :: Int]
True

>>> VU.any even (VU.empty :: VU.Vector Int)
False
Check that at least one value in the stream returns True. Subject to shortcut logic: at the first True, consumption of the stream will stop. Subject to fusion
Check if any element of a byte array satisfies a predicate
(any predicate p) determines whether any element of p satisfies the predicate.
(any predicate) returns True if any element satisfies the predicate, False otherwise
(any predicate) returns True if any byte satisfies the predicate, False otherwise
(any predicate) returns True if any character satisfies the predicate, False otherwise
any predicate stream returns True if any element in stream matches the predicate. any consumes as few elements as possible, ending consumption if an element satisfies the predicate.
ghci> is <- Streams.fromList [1, 2, 3]
ghci> Streams.any (> 0) is    -- Consumes one element
True
ghci> Streams.read is
Just 2
ghci> Streams.any even is     -- Only 3 remains
False
Determines whether any element of the structure satisfies the predicate.
O(n) any p t determines whether any character in the Text t satisfies the predicate p. Subject to fusion.
O(n) Check if any element satisfies the predicate.

Examples

>>> import qualified Data.Vector as V

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

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

>>> V.any even (V.empty :: V.Vector Int)
False