diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2016-05-22 21:50:48 -0500 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2016-05-22 21:50:48 -0500 |
commit | 7c467a66bf44626c181c7a0b22224ce73af45d31 (patch) | |
tree | 78d123fab201572ed3678f95f3729c5fd0aeaf04 /src/Mahjong/Set.hs | |
parent | 9a9206e0cbfba6073786a98096c6e5467ebaa86b (diff) | |
download | hmj-7c467a66bf44626c181c7a0b22224ce73af45d31.tar.gz hmj-7c467a66bf44626c181c7a0b22224ce73af45d31.tar.bz2 hmj-7c467a66bf44626c181c7a0b22224ce73af45d31.zip |
listen cal
Diffstat (limited to 'src/Mahjong/Set.hs')
-rw-r--r-- | src/Mahjong/Set.hs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/Mahjong/Set.hs b/src/Mahjong/Set.hs index 4c3e799..31798e5 100644 --- a/src/Mahjong/Set.hs +++ b/src/Mahjong/Set.hs @@ -1,20 +1,19 @@ module Set where -import Pai +import Tile import Data.List (sort) import Data.Char (isDigit) import Data.Either -data MSet = MSet {getMSet:: [MCard]} +type MSet = [MTile] -instance Show MSet where - show xs = fst $ foldr f ("",Nothing) $ sort $ getMSet xs - where f (MCard col n) (o,p) = let o' = show n ++ (if Just col == p then "" - else show col) ++ o in (o', Just col) +showMSet xs = fst $ foldr f ("",Nothing) $ sort xs + where f (MTile col n) (o,p) = let o' = show n ++ (if Just col == p then "" + else show col) ++ o in (o', Just col) readMSet r = fst $ foldr f ([],Man) $ map g r where g x | isDigit x = Left ((read [x])::Int) | otherwise = Right ((read [x])::MCol) - f (Left a) (xs,col) = ((MCard col a):xs,col) + f (Left a) (xs,col) = ((MTile col a):xs,col) f (Right a) (xs,col) = (xs,a) |