Exam1F05

# Exam1F05 - Student Name Design of Programming Languages...

This preview shows pages 1–3. Sign up to view the full content.

Student Name: Design of Programming Languages - Fall 2005 First Exam Oct. 11, 2005 Points: 1. 2. 3. 4. 5. 6. 7. Do any 5. In problems 1) - 3) you will use the graph v1 v2 v3 v4 v5 v6 Figure 1 : A test Directed Graph 1. (10 pts) ML and types. Consider the types, data and code exception emptyGraph of string; type vertex = {ID: int, MARK: bool ref} ref; type edge = vertex * vertex; type graph = {vertices : vertex list, edges : edge list}; fun mkGraph ([], es) = raise emptyGraph("Empty Graph: no vertices given") | mkGraph (vs, es) = {vertices= vs, edges= es}; val v1 = ref {ID=1, MARK= ref false}; 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
val v2 = ref {ID=2, MARK= ref false}; val v3 = ref {ID=3, MARK= ref false}; val v4 = ref {ID=4, MARK= ref false}; val v5 = ref {ID=5, MARK= ref false}; val v6 = ref {ID=6, MARK= ref false}; val vs = [v1,v2,v3,v4,v5,v6]; val es = [(v1,v2),(v1,v4),(v2,v3),(v5, v2),(v3,v4),(v4,v5),(v5, v1),(v5, v4)]; val g1 = mkGraph(vs, es); fun filter f [] = [] | filter f (x::y) = if (f x) then x::(filter f y) else filter f y;
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

Exam1F05 - Student Name Design of Programming Languages...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online