comparison haskell/Example/DeltaM.hs @ 138:1f218e2d9de0

Rename function in example
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Sun, 15 Feb 2015 11:31:47 +0900
parents 3f48bd08865f
children 861e35665469
comparison
equal deleted inserted replaced
137:2bf1fa6d2006 138:1f218e2d9de0
23 deltaWithLogFromList :: (Show a) => [a] -> DeltaWithLog a 23 deltaWithLogFromList :: (Show a) => [a] -> DeltaWithLog a
24 deltaWithLogFromList xs = DeltaM $ deltaFromList $ fmap returnW xs 24 deltaWithLogFromList xs = DeltaM $ deltaFromList $ fmap returnW xs
25 25
26 26
27 -- example : prime filter 27 -- example : prime filter
28 -- usage : runWriter $ checkOut 0 $ primeCountM 30 -- run specific version 28 -- usage : runWriter $ checkOut 0 $ numberCountM 30 -- run specific version
29 -- : dmap runWriter $ primeCountM 30 -- run all version 29 -- : dmap runWriter $ numberCountM 30 -- run all version
30 30
31 generatorM :: Int -> DeltaWithLog [Int] 31 generatorM :: Int -> DeltaWithLog [Int]
32 generatorM x = let intList = [1..x] in 32 generatorM x = let intList = [1..x] in
33 DeltaM $ deltaFromList $ fmap returnW $ replicate 2 intList 33 DeltaM $ deltaFromList $ fmap returnW $ replicate 2 intList
34 34
35 primeFilterM :: [Int] -> DeltaWithLog [Int] 35 numberFilterM :: [Int] -> DeltaWithLog [Int]
36 primeFilterM xs = let primeList = filter isPrime xs 36 numberFilterM xs = let primeList = filter isPrime xs
37 refactorList = filter even xs in 37 evenList = filter even xs in
38 DeltaM $ deltaFromList $ fmap returnW [primeList, refactorList] 38 DeltaM $ deltaFromList $ fmap returnW [primeList, evenList]
39 39
40 40
41 countM :: [Int] -> DeltaWithLog Int 41 countM :: [Int] -> DeltaWithLog Int
42 countM xs = let primeCount = length xs in 42 countM xs = let numberCount = length xs in
43 DeltaM $ deltaFromList $ fmap returnW $ replicate 2 primeCount 43 DeltaM $ deltaFromList $ fmap returnW $ replicate 2 numberCount
44 44
45 primeCountM :: Int -> DeltaWithLog Int 45 numberCountM :: Int -> DeltaWithLog Int
46 primeCountM x = generatorM x >>= primeFilterM >>= countM 46 numberCountM x = generatorM x >>= numberFilterM >>= countM