combinat-0.2.7.2: Generate and manipulate various combinatorial objects.

Safe Haskell None Haskell2010

Math.Combinat.Helper

Description

Miscellaneous helper functions

Synopsis

# debugging

debug :: Show a => a -> b -> b Source

# pairs

swap :: (a, b) -> (b, a) Source

pairs :: [a] -> [(a, a)] Source

pairsWith :: (a -> a -> b) -> [a] -> [b] Source

# lists

sum' :: Num a => [a] -> a Source

# equality and ordering

equating :: Eq b => (a -> b) -> a -> a -> Bool Source

reverseCompare :: Ord a => a -> a -> Ordering Source

reverseSort :: Ord a => [a] -> [a] Source

groupSortBy :: (Eq b, Ord b) => (a -> b) -> [a] -> [[a]] Source

nubOrd :: Ord a => [a] -> [a] Source

# first / last

mapWithLast :: (Bool -> a -> b) -> [a] -> [b] Source

The boolean argument will `True` only for the last element

mapWithFirst :: (Bool -> a -> b) -> [a] -> [b] Source

mapWithFirstLast :: (Bool -> Bool -> a -> b) -> [a] -> [b] Source

# older helpers for ASCII drawing

mkLinesUniformWidth :: [String] -> [String] Source

extend lines with spaces so that they have the same line

# counting

count :: Eq a => a -> [a] -> Int Source

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

# iteration

nest :: Int -> (a -> a) -> a -> a Source

unfold1 :: (a -> Maybe a) -> a -> [a] Source

unfold :: (b -> (a, Maybe b)) -> b -> [a] Source

unfoldEither :: (b -> Either c (b, a)) -> b -> (c, [a]) Source

unfoldM :: Monad m => (b -> m (a, Maybe b)) -> b -> m [a] Source

mapAccumM :: Monad m => (acc -> x -> m (acc, y)) -> acc -> [x] -> m (acc, [y]) Source

# long zipwith

longZipWith :: a -> b -> (a -> b -> c) -> [a] -> [b] -> [c] Source