Difference between revisions of "FP Laboratory 7"

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 29: Line 29:
 
<syntaxhighlight lang="Haskell">
 
<syntaxhighlight lang="Haskell">
 
flipV :: Pic -> Pic
 
flipV :: Pic -> Pic
flipV :: Pic -> Pic</syntaxhighlight>
+
flipH :: Pic -> Pic</syntaxhighlight>
 
*Place one picture above another.
 
*Place one picture above another.
 
<syntaxhighlight lang="Haskell">above :: Pic -> Pic -> Pic</syntaxhighlight>
 
<syntaxhighlight lang="Haskell">above :: Pic -> Pic -> Pic</syntaxhighlight>

Revision as of 12:40, 22 October 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
flipH :: 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