Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
-- Trükkida välja antud aasta kalender. -- -- Kasutamine: calendar 1998 module Calendar( calendar ) where import List(zip4) -- Pildid, nende kombinaatorid ja paigutamine infixr 5 $$, <> type Picture = [[Char]] height, width :: Picture -> Int height p = length p width p = length (head p) printPicture :: Picture -> IO () printPicture = putStr . unlines ($$), (<>) :: Picture -> Picture -> Picture ($$) = (++) (<>) = zipWith (++) stack, spread :: [Picture] -> Picture stack = foldr1 ($$) spread = foldr1 (<>) empty :: (Int,Int) -> Picture empty (h,w) = replicate h (replicate w ' ') block, blockT :: Int -> [Picture] -> Picture block n = stack . map spread . groups n blockT n = spread . map stack . groups n groups :: Int -> [a] -> [[a]] groups n [] = [] groups n xs = take n xs : groups n (drop n xs) lframe :: (Int,Int) -> Picture -> Picture lframe (m,n) p = (p <> empty (h,n-w)) $$ empty (m-h,n) where h = height p w = width p -- Kalendri põhifunktsioon calendar :: Int -> IO () calendar = printPicture . block 3 . map picture . months -- Ühe kuu pildi konstrueerimine picture (mn,yr,fd,ml) = title mn yr $$ table fd ml title mn yr = lframe (2,25) [mn ++ " " ++ show yr] table fd ml = lframe (8,25) (daynames <> entries fd ml) daynames = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"] entries fd ml = blockT 7 (dates fd ml) dates fd ml = map (date ml) [1-fd..42-fd] date ml d | d<1 || ml