chorale 0.1.4 → 0.1.5
raw patch · 2 files changed
+27/−2 lines, 2 filesdep ~choralePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: chorale
API changes (from Hackage documentation)
+ Chorale.Common: maximumIndex :: Ord a => [a] -> Int
+ Chorale.Common: maximumIndexBy :: Ord a => (a -> a -> Ordering) -> [a] -> Int
+ Chorale.Common: minimumIndex :: Ord a => [a] -> Int
+ Chorale.Common: minimumIndexBy :: Ord a => (a -> a -> Ordering) -> [a] -> Int
+ Chorale.Common: sublistByIndex :: (Int, Int) -> [a] -> [a]
Files
- chorale.cabal +2/−2
- src/Chorale/Common.hs +25/−0
chorale.cabal view
@@ -1,5 +1,5 @@ name: chorale-version: 0.1.4+version: 0.1.5 homepage: https://github.com/mocnik-science/chorale bug-reports: https://github.com/mocnik-science/chorale/issues synopsis: A module containing basic functions that the prelude does not offer@@ -41,7 +41,7 @@ default-language: Haskell2010 build-depends: base >= 4.6 && < 5,- chorale >= 0.1.1,+ chorale >= 0.1.5, containers >= 0.5, HUnit >= 1.2.5.2, ieee754 >= 0.7.3,
src/Chorale/Common.hs view
@@ -126,7 +126,12 @@ zipWithDefault, subset, subsets,+ sublistByIndex, findIndicesTuples,+ minimumIndex,+ minimumIndexBy,+ maximumIndex,+ maximumIndexBy, replaceInList, replaceElementInList, removeFromList,@@ -663,9 +668,29 @@ subsets [] = [[]] subsets (a:as) = uncurry (++) . map21 (id, map (a:)) . subsets $ as +-- | 'sublistByIndex' @(i, j) xs@ returns the sublist of @xs@ starting at index @i@ and ending index @j@+sublistByIndex :: (Int, Int) -> [a] -> [a]+sublistByIndex (i, j) = drop i . take (j + 1)+ -- | like 'findIndices' but results a list of tuples (x, i) where x is the list and i the index findIndicesTuples :: (a -> Bool) -> [a] -> [([a], Int)] findIndicesTuples f as = map (appendFst as) . findIndices f $ as++-- | like 'minimum' but returns the (first) index+minimumIndex :: Ord a => [a] -> Int+minimumIndex = minimumIndexBy compare++-- | like 'minimumBy' but returns the (first) index+minimumIndexBy :: Ord a => (a -> a -> Ordering) -> [a] -> Int+minimumIndexBy f = fst . minimumBy (curry $ uncurry f . map12 snd) . zip [0..]++-- | like 'maximum' but returns the (first) index+maximumIndex :: Ord a => [a] -> Int+maximumIndex = maximumIndexBy compare++-- | like 'maximumBy' but returns the (first) index+maximumIndexBy :: Ord a => (a -> a -> Ordering) -> [a] -> Int+maximumIndexBy f = fst . maximumBy (curry $ uncurry f . map12 snd) . zip [0..] -- | replace the element at the given position by a given list of elements --