Difference between revisions of "FP Laboratory 6"

From Marek Běhálek Wiki
Jump to navigation Jump to search
Line 1: Line 1:
== List of lists ==
+
== Operators ==  
Consider following type representing picture:
+
*Define following functions that performs corresponding logic operations: <code>not', and', or', nand', xor', impl', equ'</code>
 
+
*Define the 'standard' priority for all these functions, if they are used as operators.  
<syntaxhighlight lang="Haskell">type Pic = [String]</syntaxhighlight>
+
*Create a function that print
 
 
If you want to print this picture you can use:
 
 
 
<syntaxhighlight lang="Haskell">
 
pp :: Pic -> IO ()
 
pp x = putStr (concat (map (++"\n") x))
 
</syntaxhighlight>
 
 
 
Picture example:
 
 
 
<syntaxhighlight lang="Haskell">
 
pic :: Pic
 
pic = [ "....#....",
 
        "...###...",
 
        "..#.#.#..",
 
        ".#..#..#.",
 
        "....#....",
 
        "....#....",
 
        "....#####"]
 
</syntaxhighlight>
 
 
 
Create functions that:
 
 
 
*Flips picture veriticaly and horizontaly.
 
<syntaxhighlight lang="Haskell">
 
flipV :: Pic -> Pic
 
flipV :: Pic -> Pic</syntaxhighlight>
 
*Place one picture above another.
 
<syntaxhighlight lang="Haskell">above :: Pic -> Pic -> Pic</syntaxhighlight>
 
*Place two pictures side by side (consider, that they have the same height).
 
<syntaxhighlight lang="Haskell">sideBySide :: Pic -> Pic -> Pic</syntaxhighlight>
 
*Rotate picture to the left and to the right.
 
<syntaxhighlight lang="Haskell">
 
rotateR :: Pic -> Pic
 
rotateL :: Pic -> Pic</syntaxhighlight>
 
*Increase every point in the picture n times.
 
 
<syntaxhighlight lang="Haskell">zoom :: Int -> Pic -> Pic</syntaxhighlight>
 
<syntaxhighlight lang="Haskell">zoom :: Int -> Pic -> Pic</syntaxhighlight>

Revision as of 15:22, 17 September 2019

Operators

  • Define following functions that performs corresponding logic operations: not', and', or', nand', xor', impl', equ'
  • Define the 'standard' priority for all these functions, if they are used as operators.
  • Create a function that print
zoom :: Int -> Pic -> Pic