FP Test3 2024

From Marek Běhálek Wiki
Revision as of 10:00, 15 November 2024 by Beh01 (talk | contribs)
Jump to navigation Jump to search

Home Preparation For Test 3 - 2024

Data definition

Consider following type representing a maze:

type Maze = [String]

If you want to print this maze on a screen you can use:

printMaze :: Maze -> IO ()
printMaze x = putStr (concat (map (++"\n") x))

Maze example:

sample1 :: Maze
sample1 = ["*********",
           "* *   * *",
           "* * * * *",
           "* * * * *",
           "*   *   *",
           "******* *",
           "        *",
           "*********"]

sample2 :: Maze
sample2 = ["       ",
           "       ",
           "  ***  ",
           "  ***  ",
           "  ***  ",
           "       ",
           "       "]


sample3 :: Maze
sample3 = ["  * *  ",
           " ##### ",
           "  ***  ",
           "  * *  ",
           "  ***  ",
           "     * ",
           "       "]

arrow :: Maze
arrow = [ "....#....",
          "...###...",
          "..#.#.#..",
          ".#..#..#.",
          "....#....",
          "....#....",
          "....#####"]
ghci> printMaze sample1                                           
*********
* *   * *
* * * * *
* * * * *
*   *   *
******* *
        *
*********

Tasks