Practice Test III for Programming Languages course, Exams of Programming Languages

A practice test for the Programming Languages course in Fall 2014. It contains instructions, short-answer questions, and programming exercises related to topics such as map, foldr, Church booleans, and dynamic semantics of lambda calculus. The test is closed books, notes, papers, and collaboration. 4 pages long and students have 2 hours to complete it.

Typology: Exams

2013/2014

Uploaded on 05/11/2023

aarti
aarti 🇺🇸

4.5

(8)

224 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Programming Languages [Fall 2014]
Practice Test III
NAME: ______________________________________________________
Instructions:
1) This test is 4 pages in length.
2) You have 2 hours to complete and turn in this test.
3) Short-answer questions include a guideline for how many sentences to write. Respond
in complete English sentences.
4) This test is closed books, notes, papers, friends, neighbors, etc.
5) Use the backs of pages in this test packet for scratch work. If you write more than a
final answer in the area next to a question, circle your final answer.
6) Write and sign the following:
“I pledge my Honor that I have not cheated, and will not cheat, on this test.”
_______________________________________________________________________
_______________________________________________________________________
Signed: ______________________________________________
pf3
pf4

Partial preview of the text

Download Practice Test III for Programming Languages course and more Exams Programming Languages in PDF only on Docsity!

Programming Languages [Fall 2014]

Practice Test III

NAME: ______________________________________________________

Instructions:

  1. This test is 4 pages in length.

  2. You have 2 hours to complete and turn in this test.

  3. Short-answer questions include a guideline for how many sentences to write. Respond in complete English sentences.

  4. This test is closed books, notes, papers, friends, neighbors, etc.

  5. Use the backs of pages in this test packet for scratch work. If you write more than a final answer in the area next to a question, circle your final answer.

  6. Write and sign the following: “I pledge my Honor that I have not cheated, and will not cheat, on this test.”



Signed: ______________________________________________

What is a programming language? [1-2 sentences]

  1. [20 points] a) Implement map in terms of foldr (without using side effects), or if it can’t be done, briefly explain why not.

fun map F L =

b) Now implement foldr in terms of map (without using side effects), or if it can’t be done, briefly explain why not.

fun foldr F v L =

  1. [20 points] Encode an xor function in λUT. Your function must take Church booleans b 1 and b 2 and return an encoded Church boolean equivalent to b 1 xor b 2.
  2. [10 points] Define the dynamic semantics of λUT using evaluation contexts.

Define the first-order abstract syntax of diML, with all the extensions we’ve formalized in class, like aggregate data types, references, exceptions, etc. (You should also be able to define the higher-order abstract syntax and static and dynamic semantics of the fully extended version of diML. Given enough time, you should also be able to prove its soundness. )