mmsyn5 (empty) → 0.1.0.0
raw patch · 5 files changed
+106/−0 lines, 5 filesdep +basesetup-changed
Dependencies added: base
Files
- ChangeLog.md +8/−0
- Data/List/Nth.hs +51/−0
- LICENSE +20/−0
- Setup.hs +2/−0
- mmsyn5.cabal +25/−0
+ ChangeLog.md view
@@ -0,0 +1,8 @@+# Revision history for mmsyn5++## 0.1.0.0 -- 2019-11-04++* First version. Released on an unsuspecting world. Various functions + most of them are taken from the mm1 project on GitHub + (https://github.com/OleksandrZhabenko/mm1).+
+ Data/List/Nth.hs view
@@ -0,0 +1,51 @@+-- |+-- Module : Data.List.Nth+-- Copyright : (c) OleksandrZhabenko 2019+-- License : MIT+--+-- Maintainer : olexandr543@yahoo.com+--+-- Various additional operations on lists.+--++module Nth + (+ -- * Operations on lists to take a part of a list+ takeNth+ , takeWithFirst+ , dropNth+ , dropWithFirst+ -- * 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]'+takeNth :: Int -> (a -> Bool) -> [a] -> [a]+takeNth n p xs | n <= 0 = []+ | otherwise = + takeWithFirst (not . 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]'+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@+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 = ([],[])+
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2019 OleksandrZhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ mmsyn5.cabal view
@@ -0,0 +1,25 @@+-- Initial mmsyn5.cabal generated by cabal init. For further+-- documentation, see http://haskell.org/cabal/users-guide/++name: mmsyn5+version: 0.1.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+license: MIT+license-file: LICENSE+author: OleksandrZhabenko+maintainer: olexandr543@yahoo.com+-- copyright:+category: Data+build-type: Simple+extra-source-files: ChangeLog.md+cabal-version: >=1.10++library+ exposed-modules: Data.List.Nth+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.7 && <4.13+ -- hs-source-dirs: + default-language: Haskell2010