Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Various utils. Relic of the past, requires adaption to newer general purpose libs
- maybeNull :: r -> ([a] -> r) -> [a] -> r
- maybeHd :: r -> (a -> r) -> [a] -> r
- splitPlaces :: [Int] -> [e] -> [[e]]
- combineToDistinguishedEltsBy :: (e -> e -> Bool) -> [[e]] -> [[e]]
- zipWithN :: ([x] -> y) -> [[x]] -> [y]
- orderingLexic :: Ordering -> Ordering -> Ordering
- orderingLexicList :: [Ordering] -> Ordering
- panic :: [Char] -> a
- isSortedByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> Bool
- sortOnLazy :: Ord b => (a -> b) -> [a] -> [a]
- sortOn :: Ord b => (a -> b) -> [a] -> [a]
- sortByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> [a]
- groupOn :: Eq b => (a -> b) -> [a] -> [[a]]
- groupByOn :: (b -> b -> Bool) -> (a -> b) -> [a] -> [[a]]
- groupSortOn :: Ord b => (a -> b) -> [a] -> [[a]]
- groupSortByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> [[a]]
- panicJust :: String -> Maybe a -> a
Documentation
:: [Int] | places |
-> [e] | |
-> [[e]] |
Split at index places (inspired by/from split package). Places should be increasing, starting with an index >= 0. The number of sublists returned is one higher than the number of places.
Examples: >>> splitPlaces [2,3] [1,2,3,4,5,6,7] [[1,2],[3],[4,5,6,7]]
>>>
splitPlaces [6,7] [1,2,3,4,5,6,7]
[[1,2,3,4,5,6],[7],[]]
>>>
splitPlaces [0,7] [1,2,3,4,5,6,7]
[[],[1,2,3,4,5,6,7],[]]
>>>
splitPlaces [0,1,2,3,4,5,6,7] [1,2,3,4,5,6,7]
[[],[1],[2],[3],[4],[5],[6],[7],[]]
combineToDistinguishedEltsBy :: (e -> e -> Bool) -> [[e]] -> [[e]] Source #
Combine [[x1..xn],..,[y1..ym]] to [[x1..y1],[x2..y1],..,[xn..ym]]. Each element [xi..yi] is distinct based on the the key k in xi==(k,_)
orderingLexic :: Ordering -> Ordering -> Ordering Source #
Reduce compare results lexicographically using a continuation ordering
orderingLexicList :: [Ordering] -> Ordering Source #
Reduce compare results lexicographically to one compare result
isSortedByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> Bool Source #
sortOnLazy :: Ord b => (a -> b) -> [a] -> [a] Source #
A slightly more lazy version of Data.List.sortOn. See also https://github.com/UU-ComputerScience/uhc-util/issues/5 .
sortOn :: Ord b => (a -> b) -> [a] -> [a] #
Sort a list by comparing the results of a key function applied to each
element. sortOn f
is equivalent to sortBy (comparing f)
, but has the
performance advantage of only evaluating f
once for each element in the
input list. This is called the decorate-sort-undecorate paradigm, or
Schwartzian transform.
Elements are arranged from from lowest to highest, keeping duplicates in the order they appeared in the input.
Since: 4.8.0.0
groupSortOn :: Ord b => (a -> b) -> [a] -> [[a]] Source #
groupSortByOn :: (b -> b -> Ordering) -> (a -> b) -> [a] -> [[a]] Source #