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
e78a1cc1
Commit
e78a1cc1
authored
4 years ago
by
ik1g19
Browse files
Options
Downloads
Patches
Plain Diff
minor changes
parent
edc500bb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cw/src/Challenges.hs
+3
-5
3 additions, 5 deletions
cw/src/Challenges.hs
with
3 additions
and
5 deletions
cw/src/Challenges.hs
+
3
−
5
View file @
e78a1cc1
...
@@ -171,7 +171,7 @@ addStrsToGrid rg gen (s:ss) = addStrsToGrid newGrid newGen ss
...
@@ -171,7 +171,7 @@ addStrsToGrid rg gen (s:ss) = addStrsToGrid newGrid newGen ss
--| returns a list of valid orientations for the |--
--| returns a list of valid orientations for the |--
--| string at that position |--}
--| string at that position |--}
validDirs
::
RandGrid
->
String
->
Posn
->
[
Orientation
]
validDirs
::
RandGrid
->
String
->
Posn
->
[
Orientation
]
validDirs
rg
s
(
x
,
y
)
=
map
fst
$
filter
(
\
b
->
snd
b
==
True
)
(
zipF
(
checkDir
rg
s
(
x
,
y
)
)
dirs
)
validDirs
rg
s
(
x
,
y
)
=
map
fst
$
filter
(
(
True
==
)
.
snd
)
(
zipF
(
checkDir
rg
s
(
x
,
y
)
)
dirs
)
where
dirs
=
[
Forward
,
Back
,
Up
,
Down
,
UpForward
,
UpBack
,
DownForward
,
DownBack
]
where
dirs
=
[
Forward
,
Back
,
Up
,
Down
,
UpForward
,
UpBack
,
DownForward
,
DownBack
]
...
@@ -330,15 +330,13 @@ closedParse :: Parser LamExpr -> Parser LamExpr
...
@@ -330,15 +330,13 @@ closedParse :: Parser LamExpr -> Parser LamExpr
closedParse
p
=
do
e
<-
p
closedParse
p
=
do
e
<-
p
if
free
e
then
empty
else
return
e
if
free
e
then
empty
else
return
e
{--| finds if an expression contains free variables |--
{--| finds if an expression contains free variables |--}
--| |--}
free
::
LamExpr
->
Bool
free
::
LamExpr
->
Bool
free
(
LamVar
_
)
=
True
free
(
LamVar
_
)
=
True
free
(
LamAbs
x
e
)
=
freeVar
x
e
free
(
LamAbs
x
e
)
=
freeVar
x
e
free
(
LamApp
e1
e2
)
=
free
e1
&&
free
e2
free
(
LamApp
e1
e2
)
=
free
e1
&&
free
e2
{--| finds if a given variable is free in an expr |--
{--| finds if a given variable is free in an expr |--}
--| |--}
freeVar
::
Int
->
LamExpr
->
Bool
freeVar
::
Int
->
LamExpr
->
Bool
freeVar
x
(
LamVar
y
)
=
not
$
x
==
y
freeVar
x
(
LamVar
y
)
=
not
$
x
==
y
freeVar
x
(
LamAbs
y
e
)
|
x
==
y
=
False
freeVar
x
(
LamAbs
y
e
)
|
x
==
y
=
False
...
...
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