module Picture where type Picture = [String] -- vertikales, horizontales und diagonales Spiegeln flipV, flipH, flipD :: Picture -> Picture flipV = map reverse flipH = reverse flipD [] = [] flipD ([]:_) = [] flipD pic = (map head pic) : flipD (map mytail pic) where mytail [] = [] mytail xs = tail xs -- Farbinversion invertColour :: Picture -> Picture invertColour = map (map changeColour) where changeColour '#' = '.' changeColour '.' = '#' -- Bildschirmausgabe printPic :: [String] -> IO () printPic pic = putStr (concat (map (++"\n") pic)) -- Positionierung zweier Bilder übereinander und nebeneinander above, aside :: Picture -> Picture -> Picture above = (++) aside = zipWith (++) -- Übereinanderlegen zweier Bilder (gleichen Ausmasses) superimpose :: Picture -> Picture -> Picture superimpose = zipWith (zipWith blackOverWhite) where blackOverWhite '#' _ = '#' blackOverWhite '.' c = c -- Beispielbilder lambda =["............", "..##........", "....#.......", "....###.....", "...##.##....", ".##.....###.", "............" ] varwhite n = take n (repeat (take n (repeat '.'))) white = varwhite 2 blume= [".....###....", "....#####...", ".....###....", "..#...#.....", "...##.#.#...", "....###.....", "...#........"] smilie=["...######...", "..#......#..", ".#..#..#..#.", ".#........#.", ".#..#..#..#.", ".#...##...#.", "..#......#..", "...######..."]