Difference between revisions of "FP Test3 2024"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
+ | <translate> | ||
= Home Preparation For Test 3 - 2024 = | = Home Preparation For Test 3 - 2024 = | ||
+ | </translate> | ||
+ | |||
+ | <translate> | ||
+ | == Data definition == | ||
+ | </translate> | ||
<translate> | <translate> | ||
Line 22: | Line 28: | ||
<syntaxhighlight lang="Haskell"> | <syntaxhighlight lang="Haskell"> | ||
− | sample1 :: | + | sample1 :: Maze |
sample1 = ["*********", | sample1 = ["*********", | ||
"* * * *", | "* * * *", | ||
Line 32: | Line 38: | ||
"*********"] | "*********"] | ||
− | sample2 :: | + | sample2 :: Maze |
sample2 = [" ", | sample2 = [" ", | ||
" ", | " ", | ||
Line 42: | Line 48: | ||
− | sample3 :: | + | sample3 :: Maze |
sample3 = [" * * ", | sample3 = [" * * ", | ||
" ##### ", | " ##### ", | ||
Line 50: | Line 56: | ||
" * ", | " * ", | ||
" "] | " "] | ||
+ | |||
+ | arrow :: Maze | ||
+ | arrow = [ "....#....", | ||
+ | "...###...", | ||
+ | "..#.#.#..", | ||
+ | ".#..#..#.", | ||
+ | "....#....", | ||
+ | "....#....", | ||
+ | "....#####"] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="Haskell" class="myDark"> | <syntaxhighlight lang="Haskell" class="myDark"> | ||
Line 62: | Line 77: | ||
********* | ********* | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | <translate> | ||
+ | == Tasks == | ||
+ | </translate> |
Revision as of 10:00, 15 November 2024
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
*********
* * * *
* * * * *
* * * * *
* * *
******* *
*
*********