packages feed

cookbook 0.1.4.0 → 0.1.5.0

raw patch · 4 files changed

+32/−3 lines, 4 files

Files

Cookbook/Ingredients/Lists/Access.hs view
@@ -1,5 +1,5 @@ module Cookbook.Ingredients.Lists.Access(-count,contains,qsort,pull,refpos) where+count,contains,qsort,pull,refpos,areAll) where  import qualified Cookbook.Ingredients.Functional.Break as Br @@ -34,3 +34,7 @@ -- | Reference an element from one list to another. refpos :: (Eq a) => ([a],[a]) -> a -> a refpos (a,b) c = let d = (pull b (Cm.pos a c)) in case d of (Just x) -> x;(Nothing) -> c++-- | Are all elements of the list equal?+areAll :: (Eq a) => [a] -> a -> Bool+areAll x c = not $ Br.imbreak (/=c) x
+ Cookbook/Ingredients/Tupples/Assemble.hs view
@@ -0,0 +1,11 @@+module Cookbook.Ingredients.Tupples.Assemble(tupsort,assemble) where+++tupsort :: (Ord b) => [(a,b)] -> [(a,b)]+tupsort [] = []+tupsort ((a,n):xs) = lesser ++ [(a,n)] ++ greater+  where lesser   = tupsort [(c,d) | (c,d) <- xs, d <= n]+        greater = tupsort [(c,d) | (c,d) <- xs, d > n]++assemble :: (Ord b) => [(a,b)] -> [a]+assemble = (map fst) . tupsort
+ Cookbook/Recipes/Stats.hs view
@@ -0,0 +1,14 @@+module Cookbook.Recipes.Stats(frequency,mostFrequent) where++import Cookbook.Ingredients.Tupples.Assemble+import Cookbook.Ingredients.Lists.Access+import Cookbook.Ingredients.Lists.Modify+import Cookbook.Recipes.Sanitize++-- | Return a list of all elements of the list with its frequency.+frequency :: (Eq a) => [a] -> [(a,Int)] +frequency x = let y = map (\c -> (c,count x c)) x in rmdbAll y++-- | Get the x amount of most frequent items in the list.+mostFrequent :: (Eq a) => [a] -> Int -> [a]+mostFrequent x c = take c $ rev (assemble  $ frequency x)
cookbook.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.1.4.0+version:             0.1.5.0  -- A short (one-line) description of the package. synopsis:            An independent library of common haskell operations.@@ -47,7 +47,7 @@  library   -- Modules exported by the library.-  exposed-modules:     Cookbook.Common, Cookbook.Continuous, Cookbook.IO, Cookbook.Recipes.DiffStat, Cookbook.Recipes.Configuration, Cookbook.Ingredients.Functional.Break, Cookbook.Ingredients.Lists.Access, Cookbook.Ingredients.Lists.Modify, Cookbook.Ingredients.Tupples.Look, Cookbook.Recipes.Detect, Cookbook.Recipes.Groups, Cookbook.Recipes.Sanitize+  exposed-modules:     Cookbook.Common, Cookbook.Continuous, Cookbook.IO, Cookbook.Recipes.DiffStat, Cookbook.Recipes.Stats, Cookbook.Recipes.Configuration, Cookbook.Ingredients.Functional.Break, Cookbook.Ingredients.Lists.Access, Cookbook.Ingredients.Lists.Modify, Cookbook.Ingredients.Tupples.Look, Cookbook.Ingredients.Tupples.Assemble, Cookbook.Recipes.Detect, Cookbook.Recipes.Groups, Cookbook.Recipes.Sanitize      -- Modules included in this library but not exported.   -- other-modules: