Курсовая работа: Адресная книжка на Haskell

pare2 :: [String] -> [(String,String)]

pare2 [] = []

pare2 (x:xs) = if icqTest (head xs)==False then (if icqTest (head(tail xs))==False then (x++" "++(head xs)++" "++(head (tail xs)),head(tail(tail xs))):[]++pare2 (tail(tail(tail xs))) else (x++" "++head xs,head(tail xs)):[]++pare2 (tail(tail xs)) ) else (x,head xs):[]++pare2 (tail xs)

--compare E-mail and return IOF

comp :: String -> [(String,String)] -> String

comp _ [("","")] = []

comp [] _ = []

comp x (y:ys) = if x==snd y then fst y else comp x ys

--compare pares and build html table

f :: [(String,String)] -> [(String,String)] -> String

f [([],[])] _ = ""

f (x:xs) (y:ys) = (("<TR>"++"\n"++"<TD>"++comp (fst x) (y:ys)) ++"</TD>"++"\n"++"<TD>"++ snd x ++ "</TD>" ++"\n"++"<TD>"++"<a href="++"\""++"mailto:"++ fst x ++"\""++">"++fst x++"</a>"++"</TD>"++"\n"++"</TR>"++"\n") ++ (if null xs then "" else f xs (y:ys))

--write html code in out File

outFile :: String -> String -> String -> IO()

outFile x y z = do s <- readFile x; d <- readFile y;writeFile z "<HTML> \n <Body bgcolor = floralwhite> \n <TABLE border=5 alight = center> \n <TR> <TH> FIO </TH> \n <TH> ICQ </TH> \n <TH> E-mail </TH> \n </TR> \n"; appendFile z (f (pare(words s))(pare2(words d)));appendFile z "</TABLE> \n </BODY> \n </HTML>"

--GUI mode

main :: IO ()

main = start gui

gui :: IO ()

gui

= do -- main gui elements: frame, panel, text control, and the notebook

f <- frame [text := "Controls"]

p <- panel f []

nb <- notebook p []

textlog <- textCtrl p [enabled := False, wrap := WrapNone]

-- use text control as logger

textCtrlMakeLogActiveTarget textlog

logMessage "logging enabled"

-- set f [on closing :~ \prev -> do logSetActiveTarget oldlog; logDelete log; prev]

К-во Просмотров: 511
Бесплатно скачать Курсовая работа: Адресная книжка на Haskell