Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data Product = Books String String|Video String|Disk String String Int deriving Show
- getTitle :: Product -> String
- getTitle (Books a b) = a
- getTitle (Video c) = c
- getTitle (Disk e f g) = e
- getTitles :: [Product] -> [String]
- getTitles [] = []
- getTitles (x:xs) = getTitle x:getTitles xs
- getAuthor :: Product -> String
- getAuthor (Books a b) = b
- predBooks :: Product -> Bool
- predBooks (Books _ _) = True
- predBooks _ = False
- getBooks = filter predBooks
- getSome :: [Product] -> [String]
- getSome [] = []
- getSome ((Disk _ _ _):xs) = getSome xs
- getSome ((Video _):xs) = getSome xs
- getSome ((Books _ x):xs) = x:getSome xs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement