FP Test3 2024

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

Home Preparation For Test 3 - 2024

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 :: [String]
sample1 = ["*********",
           "* *   * *",
           "* * * * *",
           "* * * * *",
           "*   *   *",
           "******* *",
           "        *",
           "*********"]

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


sample3 :: [String]
sample3 = ["  * *  ",
           " ##### ",
           "  ***  ",
           "  * *  ",
           "  ***  ",
           "     * ",
           "       "]
ghci> printMaze sample1                                           
*********
* *   * *
* * * * *
* * * * *
*   *   *
******* *
        *
*********