Skip to content

Commit 118c95e

Browse files
476458476458
authored andcommitted
Changed up and down functions
1 parent 839aa5c commit 118c95e

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

_posts/2017-01-10-JoyOfOcaml1.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ match g.left with
197197
{% highlight OCaml %}
198198
(*pattern-matches on the list (of lists) , which should be non-empty, and introduces two bindings,
199199
line for the head, and above for the tail.*)
200+
200201
let up g =
201202
match g.above,g.below with
202203
| {gamegrid = line :: above},{gamegrid = below} -> (
@@ -206,28 +207,20 @@ let up g =
206207
Some (left, focus, right) ->
207208
let above = { gamegrid = above } in
208209
let below = { gamegrid = below'} in
209-
{ above
210+
Some{ above
210211
; below
211212
; left
212213
; right
213214
; focus }
214215
|None ->
215-
{ above = g.above
216-
; below = g.below
217-
; left = g.left
218-
; right = g.right
219-
; focus = g.focus }
216+
None
220217
)
221-
|({gamegrid=[]},_) -> { above = g.above
222-
; below = g.below
223-
; left = g.left
224-
; right = g.right
225-
; focus = g.focus }
218+
|({gamegrid=[]},_) -> None
226219
;;
227-
228220
{% endhighlight %}
229221

230222
{% highlight OCaml %}
223+
231224
let down g =
232225
match g.below,g.above with
233226
| {gamegrid = line :: below},{gamegrid = above} -> (
@@ -237,23 +230,15 @@ let down g =
237230
Some (left, focus, right) ->
238231
let above = { gamegrid = above } in
239232
let below = { gamegrid = above'} in
240-
{ above
233+
Some{ above
241234
; below
242235
; left
243236
; right
244237
; focus }
245238
|None ->
246-
{ above = g.above
247-
; below = g.below
248-
; left = g.left
249-
; right = g.right
250-
; focus = g.focus }
239+
None
251240
)
252-
| ({gamegrid=[]},_)-> { above = g.above
253-
; below = g.below
254-
; left = g.left
255-
; right = g.right
256-
; focus = g.focus }
241+
| ({gamegrid=[]},_)-> None
257242

258243
;;
259244
{% endhighlight %}

0 commit comments

Comments
 (0)