Difference between revisions of "FP Laboratory 6"

From Marek Běhálek Wiki
Jump to navigation Jump to search
(Created page with "== List of lists == Consider following type representing picture: <syntaxhighlight lang="Haskell">type Pic = [String]</syntaxhighlight> If you want to print this picture you...")
 
Line 15: Line 15:
 
<syntaxhighlight lang="Haskell">
 
<syntaxhighlight lang="Haskell">
 
obr :: Pic
 
obr :: Pic
obr = [ "....#....",
+
obr = [ "....#....",
      "...###...",
+
        "...###...",
"..#.#.#..",
+
        "..#.#.#..",
".#..#..#.",
+
        ".#..#..#.",
"....#....",
+
        "....#....",
"....#....",
+
        "....#....",
"....#####"]
+
        "....#####"]
 
</syntaxhighlight>
 
</syntaxhighlight>
  

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:

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

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