-- Pildid, nende kombinaatorid ja paigutamine module Pictures where 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