

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Practice problems for the midterm 2 exam of the cmsc 330, spring 2009 course. The problems cover various topics in ocaml functional programming, including modules and classes, typing, lazy evaluation, activation records, funargs, static and dynamic scoping, parameter passing, and tail recursion.
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CMSC 330, Spring 2009, Midterm 2 Practice Problems
a. What value is returned by the invocation of f( ) with static scoping? Explain. b. What value is returned by the invocation of f( ) with dynamic scoping? Explain.
Consider the following OCaml code. let app f w = let x = 1 in f w ;; let add x y = let incr z = z+x in app incr y;; (add 2 3) ;;
c. What is the order of invocation for the functions app, add, and incr when evaluating the expression (add 2 3)? d. What value is returned by (add 2 3) with static scoping? Explain. e. What value is returned by by (add 2 3) with dynamic scoping? Explain.