packages feed

mmsyn5 0.1.3.0 → 0.1.4.0

raw patch · 3 files changed

+25/−21 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -19,5 +19,9 @@  * First version revised C. Fixed an issue with the takeNth function. +## 0.1.4.0 -- 2019-11-04++* First version revised D. Fixed issues in the documentation.+  
Data/List/Nth.hs view
@@ -11,41 +11,41 @@ module Data.List.Nth    (     -- * Operations on lists to take a part of a list-       takeNth-       , takeWithFirst-       , dropNth+       takeWithFirst+       , takeNth        , dropWithFirst+       , dropNth     -- * Operation to apply a function that creates an inner list to an element of the outer list           , bGroups   ) where --- | Function that takes a list containing elements consequently up to n occurencies of @p a = True@ in @map p [a]@+-- | Function to take elements of the list after the first occurrence of @p a = False@ in @map p [a]@ excluding the element which results in the first occurrence (the first "wrong" element)+dropWithFirst :: (a -> Bool) -> ([a] -> [a])+dropWithFirst p = fst . foldr f v+  where+    f x (ys,xs) = (if p x then ys else xs,x:xs)+    v = ([],[])++-- | Function to take elements of the list till the first occurrence of @p a = False@ in @map p [a]@ including the element which results in the first occurrence (the first "wrong" element)+takeWithFirst :: (a -> Bool) -> ([a] -> [a])+takeWithFirst p = fst . foldr f v+  where+    f x (ys,xs) = (if p x then x:ys else [x],x:xs)+    v = ([],[])+    +-- | Function that takes a list containing elements consequently up to @n@ occurrencies of @p a = False@ in @map p [a]@ takeNth :: Int -> (a -> Bool) -> [a] -> [a] takeNth n p xs | n <= 0 = []                | otherwise =    takeWithFirst p xs ++ takeNth (n - 1) p (dropWithFirst p xs)  --- | Function that drops a list containing elements consequently up to n occurencies of @p a = True@ in @map p [a]@+-- | Function that drops elements from a list consequently up to @n@ occurrencies of @p a = False@ in @map p [a]@ including such occurrence dropNth :: Int -> (a -> Bool) -> [a] -> [a] dropNth n p xs | n <= 0 = xs                | otherwise =    last . take n . tail . iterate (dropWithFirst p) $ xs   --- | Function that applies additional function 'f' to @a@ if @p a = True@+-- | Function that applies additional function @f :: a -> [a]@ to @a@ if @p a = True@ bGroups :: (a -> Bool) -> (a -> [a]) -> [a] -> [a] bGroups p f = concatMap (\x -> if p x then f x else [x]) --- | Function to take elements of the list after the first occurence of @p a = True@ in @map p [a]@ excluding the element which results in the first occurance-dropWithFirst :: (a -> Bool) -> ([a] -> [a])-dropWithFirst p = fst . foldr f v-  where-    f x (ys,xs) = (if p x then ys else xs,x:xs)-    v = ([],[])---- | Function to take elements of the list till the first occurence of @p a = True@ in 'map p [a]' including the element which results in the first occurance-takeWithFirst :: (a -> Bool) -> ([a] -> [a])-takeWithFirst p = fst . foldr f v-  where-    f x (ys,xs) = (if p x then x:ys else [x],x:xs)-    v = ([],[])-    
mmsyn5.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mmsyn5-version:             0.1.3.0+version:             0.1.4.0 synopsis:            Various additional operations on lists description:         A small library to deal with a little bit more complex operations on lists than Data.List module homepage:            http://hackage.haskell.org/package/mmsyn5