-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Predicates on lists -- -- Please see the README on GitHub at -- https://github.com/pgujjula/list-utilities#readme @package list-predicate @version 0.1.0.0 -- | Predicates (True/False queries) on lists. -- -- The functions in this module are as lazy as possible. For example, -- sortedBy undefined [undefined] == True, since a list -- of one element must be sorted, no matter the comparison function, or -- the value of the element. module Data.List.Predicate -- | O(n). Whether the elements are all equal. -- --
-- >>> allEqual [1..] -- False -- -- >>> allEqual [3, 3, 3, 3] -- True -- -- >>> allEqual [] -- True -- -- >>> allEqual [1] -- True --allEqual :: Eq a => [a] -> Bool -- | O(n). Like allEqual, with a custom equality test. -- --
-- >>> allEqualBy ((==) `on` (`mod` 10)) [3, 13, 23] -- True -- -- >>> allEqualBy ((==) `on` (`mod` 10)) [3, 13, 24] -- False --allEqualBy :: (a -> a -> Bool) -> [a] -> Bool -- | O(n). Whether the elements are in sorted order. -- --
-- >>> sorted [1, 2, 3, 3] -- True -- -- >>> sorted [1, 2, 3, 2] -- False -- -- >>> sorted [] -- True -- -- >>> sorted [1] -- True --sorted :: Ord a => [a] -> Bool -- | O(n). Like sorted, with a custom comparison test. -- --
-- >>> sortedBy (comparing Down) [3, 2, 1] -- True -- -- >>> sortedBy (comparing Down) [3, 2, 1, 2] -- False --sortedBy :: (a -> a -> Ordering) -> [a] -> Bool -- | O(n log(n)). Whether the elements are all unique. -- --
-- >>> allUnique [1, 2, 5, 7] -- True -- -- >>> allUnique [1, 2, 5, 2] -- False -- -- >>> allUnique [] -- True -- -- >>> allUnique [1] -- True --allUnique :: Ord a => [a] -> Bool -- | O(n log(n)). Like allUnique, with a custom comparison -- test. -- --
-- >>> allUniqueBy (comparing head) ["apple", "bow", "cat"] -- True -- -- >>> allUniqueBy (comparing head) ["apple", "bow", "ant"] -- False --allUniqueBy :: (a -> a -> Ordering) -> [a] -> Bool -- | O(n). Whether all adjacent pairs of elements are different. -- Useful for determining whether a sorted list is all unique. -- --
-- >>> allAdjUnique [1, 2, 3, 2] -- True -- -- >>> allAdjUnique [1, 2, 2, 3] -- False -- -- >>> allAdjUnique [] -- True -- -- >>> allAdjUnique [1] -- True --allAdjUnique :: Eq a => [a] -> Bool -- | O(n). Like allAdjUnique, with a custom equality test. -- --
-- >>> allAdjUniqueBy ((==) `on` head) ["apple", "bow", "cat", "ant"] -- True -- -- >>> allAdjUniqueBy ((==) `on` head) ["apple", "ant", "bow", "cat"] -- False --allAdjUniqueBy :: (a -> a -> Bool) -> [a] -> Bool -- | O(n). Whether the list is increasing sequentially (one-by-one). -- --
-- >>> ascSequential [1, 2, 3, 4, 5] -- True -- -- >>> ascSequential [1, 2, 3, 4, 8] -- False -- -- >>> ascSequential ([] :: [Int]) -- True -- -- >>> ascSequential [1] -- True --ascSequential :: Enum a => [a] -> Bool -- | O(n). Whether the list is descending sequentially (one-by-one). -- --
-- >>> descSequential [5, 4, 3, 2, 1] -- True -- -- >>> descSequential [5, 4, 3, 3, 1] -- False -- -- >>> descSequential ([] :: [Int]) -- True -- -- >>> descSequential [1] -- True --descSequential :: Enum a => [a] -> Bool -- | O(n). Whether the input is a palindrome, i.e., the same -- forwards and backwards. -- --
-- >>> palindrome "rotor" -- True -- -- >>> palindrome "rover" -- False -- -- >>> palindrome "" -- True -- -- >>> palindrome "a" -- True --palindrome :: Eq a => [a] -> Bool