m2-fall11

# M2-fall11 - CMSC330 Fall 2011 Midterm#2 Name Discussion Time(circle one 9am 10am 11am 12pm 1pm 2pm Do not start this exam until you are told to do

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

CMSC330 Fall 2011 Midterm #2 Name Discussion Time (circle one): 9am 10am 11am 12pm 1pm 2pm Do not start this exam until you are told to do so! Instructions You have 75 minutes to take this midterm. This exam has a total of 100 points, so allocate 45 seconds for each point. This is a closed book exam. No notes or other aids are allowed. If you have a question, please raise your hand and wait for the instructor. Answer essay questions concisely using 2-3 sentences. Longer answers are not necessary and a penalty may be applied. For partial credit, show all of your work and clearly indicate your answers. Write neatly. Credit cannot be given for illegible answers. You are not allowed to use any OCaml library functions unless otherwise noted . Problem Score 1 OCaml types & type Inference /14 2 OCaml higher order & anonymous functions /15 3 OCaml polymorphic datatypes /10 4 Context free grammars /15 5 Parsing /16 6 Lambda calculus /10 7 Lambda calculus encodings /8 8 Operational semantics /12 Total /100

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

View Full Document
1. (14 pts) OCaml Types and Type Inference Give the type of the following OCaml expressions: a. (2 pts) fun x -> [x;x;x] Type = b. (3 pts) fun x y -> x y 2 Type = Write an OCaml expression with the following type: c. (2 pts) (int * int) list Code = d. (3 pts) (‘a -> int) -> int Code = Give the value of the following OCaml expressions. If an error exists, describe it e. (2 pts) let x = 3 in let x = 5 in x+1 Value / Error = f. (2 pts) let x = 4 in let x = x+6 in x+3 Value / Error =
2.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 01/13/2012 for the course CMSC 330 taught by Professor Staff during the Fall '08 term at Maryland.

### Page1 / 8

M2-fall11 - CMSC330 Fall 2011 Midterm#2 Name Discussion Time(circle one 9am 10am 11am 12pm 1pm 2pm Do not start this exam until you are told to do

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

View Full Document
Ask a homework question - tutors are online