Portability | portable |
---|---|

Stability | experimental |

Maintainer | mik@konecny.aow.cz |

Miscelaneous utilities (eg related to Ordering, pairs, booleans, strings)

- compareCompose :: Ordering -> Ordering -> Ordering
- compareComposeMany :: [Ordering] -> Ordering
- compareLex :: Ord a => [a] -> [a] -> Ordering
- compareListsWith :: (a -> a -> Ordering) -> [a] -> [a] -> Ordering
- mapFst :: (a1 -> a2) -> (a1, b) -> (a2, b)
- mapSnd :: (b1 -> b2) -> (a, b1) -> (a, b2)
- mapPair :: (a1 -> a2, b1 -> b2) -> (a1, b1) -> (a2, b2)
- mapPairHomog :: (a1 -> a2) -> (a1, a1) -> (a2, a2)
- unpair :: [(a, a)] -> [a]
- bool2maybe :: Bool -> Maybe ()
- dropLast :: Int -> [a] -> [a]
- concatWith :: String -> [String] -> String
- replicateSeveral :: [(Int, a)] -> [a]
- countDuplicates :: Eq a => [a] -> [(Int, a)]
- allCombinations :: [(k, [v])] -> [[(k, v)]]
- allPairsCombinations :: [(k, (v, v))] -> [[(k, v)]]
- allPairsCombinationsEvenOdd :: [(k, (v, v))] -> ([[(k, v)]], [[(k, v)]])
- intLog :: (Num n1, Num n2, Ord n1, Integral n2) => n1 -> n1 -> (n2, n2)
- plusDown :: Num t => t -> t -> t
- timesUp :: Num t => t -> t -> t
- timesDown :: Num t => t -> t -> t
- plusUp :: Num t => t -> t -> t
- sumDown :: Num t => [t] -> t
- productDown :: Num t => [t] -> t
- productUp :: Num t => [t] -> t
- sumUp :: Num t => [t] -> t
- readMaybe :: Read a => String -> Maybe a
- showFirstLastLines :: Show a => Int -> Int -> a -> String
- listUpdate :: Int -> a -> [a] -> [a]
- listHasMatch :: (a -> Bool) -> [a] -> Bool

# Documentation

compareCompose :: Ordering -> Ordering -> OrderingSource

Compose as when defining the lexicographical ordering.

compareComposeMany :: [Ordering] -> OrderingSource

Compose as when defining the lexicographical ordering.

compareLex :: Ord a => [a] -> [a] -> OrderingSource

The lexicographical ordering.

compareListsWith :: (a -> a -> Ordering) -> [a] -> [a] -> OrderingSource

mapPairHomog :: (a1 -> a2) -> (a1, a1) -> (a2, a2)Source

bool2maybe :: Bool -> Maybe ()Source

replicateSeveral :: [(Int, a)] -> [a]Source

eg

replicateSeveral [(2,"a"),(1,"b")] = "aab"

countDuplicates :: Eq a => [a] -> [(Int, a)]Source

eg

countDuplicates "aaba" = [(2,"a"),(1,"b"),(1,"a")]

allCombinations :: [(k, [v])] -> [[(k, v)]]Source

eg

allCombinations [ (1,['a']), (2,['b','c']), (3,['d','e','f']) ] = [ [(1,'a'),(2,'b'),(3,'d')], [(1,'a'),(2,'b'),(3,'e')], [(1,'a'),(2,'b'),(3,'f')], [(1,'a'),(2,'c'),(3,'d')], [(1,'a'),(2,'c'),(3,'e')], [(1,'a'),(2,'c'),(3,'f')] ]

allPairsCombinations :: [(k, (v, v))] -> [[(k, v)]]Source

allPairsCombinationsEvenOddSource

:: [(k, (v, v))] | the first value is even, the second odd |

-> ([[(k, v)]], [[(k, v)]]) |

eg

allPairsCombinationsEvenOdd [ (1,('a0','a1'), (2,('b0','b1'), (3,('c0','c1') ] = ([ [(1,'a0'),(2,'b0'),(3,'c0')], [(1,'a0'),(2,'b1'),(3,'c1')], [(1,'a1'),(2,'b1'),(3,'c0')], [(1,'a1'),(2,'b0'),(3,'c1')] ] ,[ [(1,'a0'),(2,'b0'),(3,'c1')], [(1,'a0'),(2,'b1'),(3,'c0')], [(1,'a1'),(2,'b0'),(3,'c0')], [(1,'a1'),(2,'b1'),(3,'c1')] ] )

productDown :: Num t => [t] -> tSource

listUpdate :: Int -> a -> [a] -> [a]Source

listHasMatch :: (a -> Bool) -> [a] -> BoolSource