Copyright | (c) 2021 Rudy Matela |
---|---|
License | 3-Clause BSD (see the file LICENSE) |
Maintainer | Rudy Matela <rudy@matela.com.br> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- module Data.List
- module Data.Function
- module Data.Maybe
- module Data.Monoid
- module Data.Tuple
- module Data.Typeable
- count :: (a -> Bool) -> [a] -> Int
- nubOn :: Eq b => (a -> b) -> [a] -> [a]
- nubSort :: Ord a => [a] -> [a]
- mzip :: Monoid a => [a] -> [a] -> [a]
- groupOn :: Eq b => (a -> b) -> [a] -> [[a]]
- idIO :: (a -> IO ()) -> a -> a
- mapHead :: (a -> a) -> [a] -> [a]
- sets :: [a] -> [[a]]
- headOr :: a -> [a] -> a
- allEqual :: Eq a => [a] -> Bool
- allEqualOn :: Eq b => (a -> b) -> [a] -> Bool
- allEqual2 :: Eq a => [a] -> Bool
- choices :: [a] -> [(a, [a])]
- choicesThat :: (a -> [a] -> Bool) -> [a] -> [(a, [a])]
- foldr0 :: (a -> a -> a) -> a -> [a] -> a
- indent :: String -> String
- indentBy :: Int -> String -> String
- classify :: Eq a => [a] -> [[a]]
- classifyBy :: (a -> a -> Bool) -> [a] -> [[a]]
- classifyOn :: Eq b => (a -> b) -> [a] -> [[a]]
- none :: (a -> Bool) -> [a] -> Bool
- updateAt :: Int -> (a -> a) -> [a] -> [a]
- first :: (a -> a') -> (a, b) -> (a', b)
- second :: (b -> b') -> (a, b) -> (a, b')
- both :: (a -> b) -> (a, a) -> (b, b)
- (+++) :: Ord a => [a] -> [a] -> [a]
Documentation
module Data.List
module Data.Function
module Data.Maybe
module Data.Monoid
module Data.Tuple
module Data.Typeable
mzip :: Monoid a => [a] -> [a] -> [a] Source #
Zips Monoid
values leaving trailing values.
> mzip ["ab","cd"] ["ef"] ["abef","cd"]
idIO :: (a -> IO ()) -> a -> a Source #
WARNING:
uses unsafePerformIO
and should only be used for debugging!
> idIO print 10 10 10
Return sets of values based on the list.
The values in the list must me unique.
allEqualOn :: Eq b => (a -> b) -> [a] -> Bool Source #
allEqual2 :: Eq a => [a] -> Bool Source #
Checks if all elements of a list are equal.
Exceptionally this function returns false for an empty or unit list.
This returns true when all elements are equal and the list has a length greater than or equal to two.
choicesThat :: (a -> [a] -> Bool) -> [a] -> [(a, [a])] Source #
Lists choices of values that follow a property.
foldr0 :: (a -> a -> a) -> a -> [a] -> a Source #
A variation of foldr that only uses "zero" when the list is empty
indentBy :: Int -> String -> String Source #
Indents a block of text with the provided amount of spaces
classify :: Eq a => [a] -> [[a]] #
Classify values using their Eq
instance.
> classify [1,2,3,1,2,1] [[1,1,1],[2,2],[3]]
(cf. classifyBy
, classifyOn
)
classifyBy :: (a -> a -> Bool) -> [a] -> [[a]] #
Classify values by a given comparison function.
> classifyBy (\(x,_) (y,_) -> x == y) [(1,1),(1,2),(2,1),(2,2)] [[(1,1),(1,2)],[(2,1),(2,2)]]
(cf. classify
, classifyOn
)
classifyOn :: Eq b => (a -> b) -> [a] -> [[a]] #
Classify values based on the result of a given function.
> classifyOn head ["sheep", "chip", "ship", "cheap"] [["sheep","ship"],["chip","cheap"]]
> classifyOn odd [1,2,3,4,5,6] [[1,3,5],[2,4,6]]
(cf. classify
, classifyBy
)
updateAt :: Int -> (a -> a) -> [a] -> [a] Source #
Updates the value in a list at a given position.
> updateAt 2 (*10) [1,2,3,4] [1,2,30,4]
first :: (a -> a') -> (a, b) -> (a', b) Source #
Applies a function to the first element of a pair.
Often known on the wild as mapFst
.
> first (*10) (1,2) (10,2)