FinalF05 - Design of Programming Languages - Fall 2005...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Design of Programming Languages - Fall 2005 Final Exam December 20, 2005 Do any 9. 1. (10 pts) Operational Semantics and Type Judgments in Impcore . (5 pts) Give the operational semantics for (begin e1 . .. en) , where n 0. (5 pts) You are given the ARRAY-SET type judgment: Γ ξ , Γ φ , Γ ρ e 1 : ARRAY( τ ) Γ ξ , Γ φ , Γ ρ e 2 : INT Γ ξ , Γ φ , Γ ρ e 3 : τ Γ ξ , Γ φ , Γ ρ ARRAY-SET( e 1 , e 2 , e 3 ) : τ Within the functiom fun typeof (e, globals, functions, formals) of typed Impcore, you have the function ty , which takes only the expression e as an argument, using the remaining arguments of typeof as free variables and returns the type of its argument according to the type judgment above. Write the code completing ty(ASET(a, i, t)) where (ASET(a, i, t)) is the appropriate form of the expression e . 2. (10 pts) Higher Order Functions - either μ Scheme or ML. foldl is a function that normally takes three parameters, a binary operator , a default value and a list. Its semantics can be described as: (foldl ⊕ ℵ ’( v 1 , v 2 , ··· , v n )) = v n ( v n 1 ( ··· ⊕ ( v 1 ⊕ ℵ ) ··· )). (5 pts) DeFne a Curried version of foldl . (5 pts) Using this version of foldl deFne a function - in the same language as the Frst part - that will take a list of integers and return the sum of their squares. You must apply foldl to an appropriate binary operator and an appropriate default value. 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
3. (10 pts) Lambda Calculus . (5 pts) Consider the λ -expression Θ 1 = ( λx.λy. ( y ( x x y )))( λx.λy. ( y ( x x y ))) . Show that it is a fxed-point combinator . This is known as the Turing fxed-point combinator . (5 poits) Consider Θ 2 = ( λx.λy. ( y ( λz.x x y z )))( λx.λy. ( y ( λz.x x y z ))) This is a second form of Turing’s Fxed-point combinator. Explain the conditions under which you would use one or the other form of the combinator. A simple example would
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

FinalF05 - Design of Programming Languages - Fall 2005...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online