{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

m2-fall11

# m2-fall11 - CMSC330 Fall 2011 Midterm#2 Name Discussion...

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.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern