-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathassignment7sub.ml
More file actions
71 lines (59 loc) · 1.75 KB
/
assignment7sub.ml
File metadata and controls
71 lines (59 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(* Programming Languages, Assignment 7 *)
(*
You should write your functions in this file.
You should NOT specify the types of your functions. Let the system determine
them for you.
The instructions for this assignment reside in an auxiliary file, assignment7doc.md
You should start by reading that file.
*)
(* ---------------------------------
HELPERS
---------------------------------
Place your "helpers" implementations here.
*)
let rec range a b = if a > b then [] else a :: range (a + 1) b
(* ---------------------------------
PICTURES
---------------------------------
Place our Pictures implementations here after the type declarations and
sword definition.
*)
type pixel = D | H
type row = pixel list
type pic = row list
exception IncompatibleDims
let sword = [
[D;D;D;D;D;D;D;D;D;D;D;D;D;D;D;D];
[D;H;H;D;D;D;D;D;D;D;D;D;D;D;D;D];
[D;H;H;H;H;D;D;D;D;D;D;D;D;D;D;D];
[D;D;H;H;H;H;D;D;D;D;D;D;D;D;D;D];
[D;D;H;H;H;H;H;D;D;D;D;D;D;D;D;D];
[D;D;D;H;H;H;H;D;D;D;D;D;D;D;D;D];
[D;D;D;D;H;H;H;H;D;D;D;D;D;D;D;D];
[D;D;D;D;D;D;H;H;H;D;D;D;D;D;D;D];
[D;D;D;D;D;D;D;H;H;H;D;D;H;D;D;D];
[D;D;D;D;D;D;D;D;H;H;D;H;H;D;D;D];
[D;D;D;D;D;D;D;D;D;D;H;H;D;D;D;D];
[D;D;D;D;D;D;D;D;D;H;H;H;D;D;D;D];
[D;D;D;D;D;D;D;D;H;H;D;D;H;D;D;D];
[D;D;D;D;D;D;D;D;D;D;D;D;D;H;D;D];
[D;D;D;D;D;D;D;D;D;D;D;D;D;D;H;H];
[D;D;D;D;D;D;D;D;D;D;D;D;D;D;H;H]]
(*
You need to fix this.
*)
let doodad = []
(*
These two functions provided to you. Study how they work before continuing!
*)
let valid_pic pic =
match List.map List.length pic with
| [] -> true
| x :: xs -> List.for_all ((=) x) xs
let dims_pic pic =
match pic with
| [] -> (0, 0)
| row :: _ -> (List.length pic, List.length row)
(*
Add your other functions here
*)