packages feed

mmsyn5 0.1.4.0 → 0.2.0.0

raw patch · 3 files changed

+13/−35 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Data.List.Nth: bGroups :: (a -> Bool) -> (a -> [a]) -> [a] -> [a]
- Data.List.Nth: dropNth :: Int -> (a -> Bool) -> [a] -> [a]
- Data.List.Nth: dropWithFirst :: (a -> Bool) -> ([a] -> [a])
- Data.List.Nth: takeNth :: Int -> (a -> Bool) -> [a] -> [a]
- Data.List.Nth: takeWithFirst :: (a -> Bool) -> ([a] -> [a])
+ Data.List.Nth: mapI :: (a -> Bool) -> (a -> [a]) -> [a] -> [a]
+ Data.List.Nth: mapI2 :: (a -> Bool) -> (a -> b) -> (a -> [b]) -> [a] -> [b]

Files

ChangeLog.md view
@@ -23,5 +23,8 @@  * First version revised D. Fixed issues in the documentation. +## 0.2.0.0 -- 2019-11-04++* Second version. Changed the basic idea of what operations are included.  
Data/List/Nth.hs view
@@ -10,42 +10,17 @@  module Data.List.Nth    (-    -- * Operations on lists to take a part of a list-       takeWithFirst-       , takeNth-       , dropWithFirst-       , dropNth     -- * Operation to apply a function that creates an inner list to an element of the outer list   -       , bGroups+       mapI+       , mapI2   ) where --- | 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 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 :: 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])+mapI :: (a -> Bool) -> (a -> [a]) -> [a] -> [a]+mapI p f = concatMap (\x -> if p x then f x else [x])+{-#INLINE mapI#-} +-- | Function that applies additional function @f :: a -> b@ to @a@ if @p a = True@ and otherwise another function @g :: a -> [b]@  to @[a]@ to obtain @[b]@+mapI2 :: (a -> Bool) -> (a -> b) -> (a -> [b]) -> [a] -> [b]+mapI2 p f g = concatMap (\x -> if p x then [f x] else g x)+{-#INLINE mapI2#-}
mmsyn5.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                mmsyn5-version:             0.1.4.0+version:             0.2.0.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