Mercurial > hg > Members > atton > delta_monad
changeset 135:bb0b2fb49a93
Update Example
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 07 Feb 2015 14:43:20 +0900 |
parents | 3f48bd08865f |
children | b6dcbe8617a9 |
files | haskell/Example/Delta.hs |
diffstat | 1 files changed, 7 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/haskell/Example/Delta.hs Fri Feb 06 16:28:54 2015 +0900 +++ b/haskell/Example/Delta.hs Sat Feb 07 14:43:20 2015 +0900 @@ -3,34 +3,20 @@ import Data.Numbers.Primes import Delta --- samples +-- examples generator :: Int -> Delta [Int] generator x = let intList = [1..x] in return intList -primeFilter :: [Int] -> Delta [Int] -primeFilter xs = let primeList = filter isPrime xs - refactorList = filter even xs in - deltaFromList [ primeList, refactorList] +numberFilter :: [Int] -> Delta [Int] +numberFilter xs = let primeList = filter isPrime xs + evenList = filter even xs in + Delta evenList (Mono primeList) count :: [Int] -> Delta Int count xs = let primeCount = length xs in return primeCount -primeCount :: Int -> Delta Int -primeCount x = generator x >>= primeFilter >>= count - -bubbleSort :: [Int] -> Delta [Int] -bubbleSort [] = return [] -bubbleSort xs = bubbleSort remainValue >>= (\xs -> deltaFromList [ (sortedValueL : xs), - (sortedValueR ++ xs)] ) - where - maximumValue = maximum xs - sortedValueL = maximumValue - sortedValueR = replicate (length $ filter (== maximumValue) xs) maximumValue - remainValue = filter (/= maximumValue) xs - - - - +numberCount :: Int -> Delta Int +numberCount x = generator x >>= numberFilter >>= count