FP Test3 2024
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
*********
* * * *
* * * * *
* * * * *
* * *
******* *
*
*********