

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
An outline of the topics to be covered in exam #2 for the cs 405/505 programming languages course. The exam will consist of various question types, including fill in the blank, true or false, multiple choice, short answer, and discussion questions. Topics include programming languages semantics, functional programming languages, and logic programming. Students should have a solid understanding of denotational and axiomatic semantics, functional programming concepts, and prolog rule matching and list representation.
Typology: Exams
1 / 3
This page cannot be seen from the preview
Don't miss anything!


November 6, 2007
The exam will cover everything we have discussed from Chapters 3 (i.e. Section 3.5), 15, and 16 in the text and all notes, but emphasizing the material covered in class. The style of the exam will be very flexible, possibly consisting of fill in the blank, true or false (possibly with justification), multiple choice, matching, short answer (e.g. definitions or listing), and discussion questions. You will not be asked to work detailed problems such as writing any actual code (i.e. code in a specific language like Lisp or Prolog) You should have some ideas about the theory behind implementation of programming languages (e.g. the relationship between formal models of computation and programming languages, λ-calculus etc.). Some smaller problems such as drawing a Lisp representation of a list, or tracing the execution of a Prolog program, are likely.
A brief outline of the topics we have covered is described below. (This list is intended to be as complete as possible but may not be all inclusive.)
(defun update (store V n) (prog (currentenv newbinding newstore) (setq currentenv (cdaddr store))) (setq newbinding (cons (list ’eq ’V (list ’quote V)) (list n))) (setq newstore (list ’lambda (list ’V) (cons ’cond (cons newbinding currentenv)))) (return newstore))))
Note that the (prog (list of local variables) (exp-1) (exp-2) ... (exp-n) (return exp)) construction declares a list of local variables used in the expressions with exp being the value returned. Let S represent the Lisp expression (lambda (V) (cond ((eq V (quote x)) 4) (t (quote bottom)))). What is the internal list representation that Lisp uses for S? What is (cdaddr S)? Trace the execution of (update S ’x 5), showing the values of currentenv, newbinding, and newstore.
hanoi(N) :- move(N, left, center, right).
move(0, X, Y, Z). move(N, X, Y, Z) :- N > 0, M is N - 1, move(M, X, Z, Y), display([X,Y]), move(M, Z, Y, X).
Trace the above program using the query hanoi(3). Show all queries which are generated by the execution and all moves which are printed. You may wish to draw a tree to show this clearly.