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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ik1g19
prog3-coursework
Commits
89a62282
Commit
89a62282
authored
4 years ago
by
ik1g19
Browse files
Options
Downloads
Patches
Plain Diff
removed findPlacement repetition
parent
1166ca9a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cw/src/Challenges.hs
+12
-14
12 additions, 14 deletions
cw/src/Challenges.hs
with
12 additions
and
14 deletions
cw/src/Challenges.hs
+
12
−
14
View file @
89a62282
...
@@ -66,21 +66,19 @@ findLocation css (x,y) s@(l:ls) | x > limit && y > limit = N
...
@@ -66,21 +66,19 @@ findLocation css (x,y) s@(l:ls) | x > limit && y > limit = N
{--| checks for hidden word in possible directions |--}
{--| checks for hidden word in possible directions |--}
findPlacement
::
WordSearchGrid
->
Posn
->
String
->
Maybe
Placement
findPlacement
::
WordSearchGrid
->
Posn
->
String
->
Maybe
Placement
findPlacement
css
(
x
,
y
)
s
|
checkWordDir
css
(
x
,
y
)
Forward
s
=
Just
((
x
,
y
),
Forward
)
findPlacement
css
(
x
,
y
)
s
=
findP
dirs
|
checkWordDir
css
(
x
,
y
)
Back
s
=
Just
((
x
,
y
),
Back
)
where
|
checkWordDir
css
(
x
,
y
)
Up
s
=
Just
((
x
,
y
),
Up
)
findP
[]
=
Nothing
|
checkWordDir
css
(
x
,
y
)
Down
s
=
Just
((
x
,
y
),
Down
)
findP
(
d
:
ds
)
|
checkWordDir
css
(
x
,
y
)
s
d
=
Just
(
(
x
,
y
),
d
)
|
checkWordDir
css
(
x
,
y
)
UpForward
s
=
Just
((
x
,
y
),
UpForward
)
|
otherwise
=
findP
ds
|
checkWordDir
css
(
x
,
y
)
UpBack
s
=
Just
((
x
,
y
),
UpBack
)
|
checkWordDir
css
(
x
,
y
)
DownForward
s
=
Just
((
x
,
y
),
DownForward
)
dirs
=
[
Forward
,
Back
,
Up
,
Down
,
UpForward
,
UpBack
,
DownForward
,
DownBack
]
|
checkWordDir
css
(
x
,
y
)
DownBack
s
=
Just
((
x
,
y
),
DownBack
)
|
otherwise
=
Nothing
checkWordDir
::
WordSearchGrid
->
Posn
->
String
->
Orientation
->
Bool
checkWordDir
css
(
x
,
y
)
(
l
:
[]
)
dir
|
nextElem
css
(
x
,
y
)
dir
==
Just
l
=
True
checkWordDir
::
WordSearchGrid
->
Posn
->
Orientation
->
String
->
Bool
checkWordDir
css
(
x
,
y
)
dir
(
l
:
[]
)
|
nextElem
css
(
x
,
y
)
dir
==
Just
l
=
True
|
otherwise
=
False
|
otherwise
=
False
checkWordDir
css
(
x
,
y
)
dir
(
l
:
ls
)
|
nextElem
css
(
x
,
y
)
dir
==
Just
l
=
checkWordDir
css
(
nextPos
dir
(
x
,
y
))
dir
ls
checkWordDir
css
(
x
,
y
)
(
l
:
ls
)
dir
|
nextElem
css
(
x
,
y
)
dir
==
Just
l
=
checkWordDir
css
(
nextPos
dir
(
x
,
y
))
ls
dir
|
otherwise
=
False
|
otherwise
=
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