Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data Notebook = Reminder String Int Int | -- saxeli, ricxvi, tve
- Tel String Int | -- saxeli, telefoni
- Meeting Int Int Int String deriving (Eq, Show) -- ricxvi, tve, saati, shemxvedri
- -- amocana N1 (gadavcemt saxels - gvibrunebs telefonis nomers)
- getTel :: [Notebook] -> String -> Int
- getTel [] _ = 0
- getTel ((Tel a b):xs) name = if (a == name) then b
- else getTel xs name
- getTel (x:xs) name = getTel xs name
- -- amocana N2 (gadavcemt saxels - gvibrunebs dabadebis ricxvs da tves)
- getDate :: [Notebook] -> String -> [Int]
- getDate [] _ = []
- getDate ((Reminder a n1 n2):xs) name = if (a == name) then [n1, n2]
- else getDate xs name
- getDate (x:xs) name = getDate xs name
- -- amocana N3
- getByName :: [Notebook] -> String -> [Int]
- getByName [] _ = []
- getByName (x:xs) name = if ((getTel (x:xs) name == 0) || (getDate (x:xs) name == [0,0])) then []
- else (getTel (x:xs) name):(getDate (x:xs) name)
- -- amocana N4 (gadavcemt Char-s - gvibrunebs saxelebs am Char-it dawyebuls)
- getByLetter :: [Notebook] -> Char-> [String]
- getByLetter [] _ = []
- getByLetter (x:xs) chr = case x of
- Reminder y _ _ -> if (chr == head(y)) then y:getByLetter xs chr
- else getByLetter xs chr
- Tel y _ -> if (chr == head(y)) then y:getByLetter xs chr
- else getByLetter xs chr
- Meeting _ _ _ _ -> getByLetter xs chr
- {- getNameChar [] n = (-1)
- getNameChar (x:xs) 0 = x
- getNameChar (x:xs) n = getNameChar xs (n-1) -}
- -- amocana N5 (gadavcemt ricxvs, tves, saats - gvibrunebs saxels shexvedris + dros)
- getMeeting :: [Notebook] -> Int -> Int -> Int -> [(String,[Int])]
- getMeeting [] _ _ _ = []
- getMeeting ((Meeting n1 n2 n3 name):xs) a b c =
- if ((n1 == a) && (n2 == b) && (n3 == c))
- then (name, [a, b, c]):getMeeting xs a b c
- else getMeeting xs a b c
- getMeeting (x:xs) a b c = getMeeting xs a b c
- -- amocana N6
- getReminder :: [Notebook] -> Int -> Int -> [String]
- getReminder [] _ _ = []
- getReminder ((Reminder name n1 n2):xs) a b =
- if (n1 == a && n2 == b)
- then name:getReminder xs a b
- else getReminder xs a b
- getReminder (x:xs) a b = getReminder xs a b
- -- amocana N7
- getTel2 :: [Notebook] -> Int -> [(String, [Int])]
- getTel2 [] _ = []
- getTel2 ((Reminder name n1 n2):xs) num =
- if (num == getTel ((Reminder name n1 n2):xs) name)
- then (name, [getTel ((Reminder name n1 n2):xs) name]):getTel2 xs num
- else getTel2 xs num
- getTel2 (x:xs) num = getTel2 xs num
- -- amocana N8 (NOT WORKING)
- getAssigment :: [Notebook] -> Int -> Int -> Int -> [(String, [Int])]
- getAssigment xs a b c = (getMeeting xs a b c) ++ (getTel2 xs getByName)
Advertisement
Add Comment
Please, Sign In to add comment