Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
prog3-coursework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ik1g19
prog3-coursework
Commits
edc500bb
Commit
edc500bb
authored
4 years ago
by
ik1g19
Browse files
Options
Downloads
Patches
Plain Diff
starting test work on challenge 4
parent
89a62282
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cw/src/Challenges.hs
+1
-1
1 addition, 1 deletion
cw/src/Challenges.hs
cw/test/Spec.hs
+42
-7
42 additions, 7 deletions
cw/test/Spec.hs
with
43 additions
and
8 deletions
cw/src/Challenges.hs
+
1
−
1
View file @
edc500bb
...
...
@@ -7,7 +7,7 @@
-- DO NOT MODIFY THE FOLLOWING LINES OF CODE
module
Challenges
(
WordSearchGrid
,
Placement
,
Posn
,
Orientation
(
..
),
solveWordSearch
,
createWordSearch
,
LamMacroExpr
(
..
),
LamExpr
(
..
),
prettyPrint
,
parseLamMacro
,
cpsTransform
,
innerRedn1
,
outerRedn1
,
compareInnerOuter
,
unique
,
macroName
,
closedParse
,
expr
)
where
cpsTransform
,
innerRedn1
,
outerRedn1
,
compareInnerOuter
)
where
-- Import standard library and parsing definitions from Hutton 2016, Chapter 13
-- We import System.Random - make sure that your installation has it installed - use stack ghci and stack ghc
...
...
This diff is collapsed.
Click to expand it.
cw/test/Spec.hs
+
42
−
7
View file @
edc500bb
import
Challenges
import
Data.List
main
::
IO
()
main
=
challenge2Test
-------------------------------------Examples-----------------------------------
exGrid1'1
=
[
"HAGNIRTSH"
,
"SACAGETAK"
,
"GCSTACKEL"
,
"MGHKMILKI"
,
"EKNLETGCN"
,
"TNIRTLETE"
,
"IRAAHCLSR"
,
"MAMROSAGD"
,
"GIZKDDNRG"
]
exWords1'1
=
[
"HASKELL"
,
"STRING"
,
"STACK"
,
"MAIN"
,
"METHOD"
]
exAns1'1
=
[(
"HASKELL"
,
Just
((
0
,
0
),
DownForward
)),(
"STRING"
,
Just
((
7
,
0
),
Back
)),(
"STACK"
,
Just
((
2
,
2
),
Forward
)),
(
"MAIN"
,
Just
((
2
,
7
),
Up
)),(
"METHOD"
,
Just
((
4
,
3
),
Down
))]
exGrid1'2
=
[
"ROBREUMBR"
,
"AURPEPSAN"
,
"UNLALMSEE"
,
"YGAUNPYYP"
,
"NLMNBGENA"
,
"NBLEALEOR"
,
"ALRYPBBLG"
,
"NREPBEBEP"
,
"YGAYAROMR"
]
exWords1'2
=
[
"BANANA"
,
"ORANGE"
,
"MELON"
,
"RASPBERRY"
,
"APPLE"
,
"PLUM"
,
"GRAPE"
]
exAns1'2
=
[(
"BANANA"
,
Just
((
5
,
6
),
UpBack
)),(
"ORANGE"
,
Just
((
1
,
0
),
DownForward
)),(
"MELON"
,
Just
((
7
,
8
),
Up
)),
(
"RASPBERRY"
,
Just
((
8
,
0
),
DownBack
)),(
"APPLE"
,
Just
((
2
,
8
),
UpForward
)),(
"PLUM"
,
Just
((
5
,
1
),
DownBack
)),
(
"GRAPE"
,
Just
((
8
,
6
),
Up
))]
exGrid1'3
=
[
"TEST"
,
"ASBD"
,
"GDFI"
,
"FDGS"
]
exWords1'3
=
[
"TEST"
]
exAns1'3
=
[(
"TEST"
,
Just
((
0
,
0
),
Forward
))]
ex3'1
=
LamDef
[]
(
LamApp
(
LamAbs
1
(
LamVar
1
))
(
LamAbs
1
(
LamVar
1
)))
ex3'2
=
LamDef
[]
(
LamAbs
1
(
LamApp
(
LamVar
1
)
(
LamAbs
1
(
LamVar
1
))))
ex3'3
=
LamDef
[
(
"F"
,
LamAbs
1
(
LamVar
1
)
)
]
(
LamAbs
2
(
LamApp
(
LamVar
2
)
(
LamMacro
"F"
)))
ex3'4
=
LamDef
[
(
"F"
,
LamAbs
1
(
LamVar
1
)
)
]
(
LamAbs
2
(
LamApp
(
LamAbs
1
(
LamVar
1
))
(
LamVar
2
)))
ex3'5
=
LamDef
[
(
"F"
,
LamAbs
1
(
LamApp
((
LamVar
1
)
(
LamVar
1
))
),
(
"G"
,
LamAbs
2
(
LamVar
2
)
)
]
()
ex3'1Ans
=
"(
\\
x1 -> x1)
\\
x1 -> x1"
ex3'2Ans
=
"
\\
x1 -> x1
\\
x1 -> x1"
ex3'3Ans
=
"def F =
\\
x1 -> x1 in
\\
x2 -> x2 F"
ex3'4Ans
=
"def F =
\\
x1 -> x1 in
\\
x2 -> F x2"
ex3'5Ans
=
"def F =
\\
x1 -> x1 x1 in def G =
\\
x2 -> x2 in F G"
------------------------------Printing Functions--------------------------------
printGrid
::
WordSearchGrid
->
IO
()
printGrid
[]
=
return
()
...
...
@@ -39,6 +52,16 @@ pPrintList cs = do putStr "["
ppl
$
xs
-------------------------------------Main---------------------------------------
main
::
IO
()
main
=
do
challenge1Test
challenge2Test
-----------------------------Challenge 1 Testing--------------------------------
assert1
::
WordSearchGrid
->
[
(
String
,
Maybe
Placement
)
]
->
[
(
String
,
Maybe
Placement
)
]
->
IO
()
assert1
grid
result
correct
|
result
==
correct
=
do
putStrLn
"Testing Grid:
\n
"
...
...
@@ -60,8 +83,10 @@ challenge1Test = do putStrLn "Challenge 1 Start Test"
assert1
exGrid1'1
(
solveWordSearch
exWords1'1
exGrid1'1
)
exAns1'1
assert1
exGrid1'2
(
solveWordSearch
exWords1'2
exGrid1'2
)
exAns1'2
putStrLn
"========================================="
putStrLn
"Challenge 1 End Test"
putStrLn
"Challenge 1 End Test
\n
"
-----------------------------Challenge 2 Testing--------------------------------
assert2
::
WordSearchGrid
->
[
(
String
,
Maybe
Placement
)
]
->
IO
()
...
...
@@ -87,3 +112,13 @@ challenge2Test = do putStrLn "Challenge 2 Start Test"
assert2
g1
sol1
putStrLn
"========================================="
putStrLn
"Challenge 2 End Test"
-----------------------------Challenge 3 Testing--------------------------------
assert3
-- challenge3Test
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment