Difference between revisions of "FP Laboratory 6"

From Marek Běhálek Wiki
Jump to navigation Jump to search
Line 14: Line 14:
  
 
<syntaxhighlight lang="Haskell">
 
<syntaxhighlight lang="Haskell">
obr :: Pic
+
pic :: Pic
obr = [ "....#....",
+
pic = [ "....#....",
 
         "...###...",
 
         "...###...",
 
         "..#.#.#..",
 
         "..#.#.#..",

Revision as of 14:45, 17 September 2019

List of lists

Consider following type representing picture:

type Pic = [String]

If you want to print this picture you can use:

pp :: Pic -> IO ()
pp x = putStr (concat (map (++"\n") x))

Picture example:

pic :: Pic
pic = [ "....#....",
        "...###...",
        "..#.#.#..",
        ".#..#..#.",
        "....#....",
        "....#....",
        "....#####"]

Create functions that:

  • Flips picture veriticaly and horizontaly.
flipV :: Pic -> Pic
flipV :: Pic -> Pic
  • Place one picture above another.
above :: Pic -> Pic -> Pic
  • Place two pictures side by side (consider, that they have the same height).
sideBySide :: Pic -> Pic -> Pic
  • Rotate picture to the left and to the right.
rotateR :: Pic -> Pic
rotateL :: Pic -> Pic
  • Increase every point in the picture n times.
zoom :: Int -> Pic -> Pic