

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


You should review the questions from the sample midterm exams, the real midterm exams, and the homework, as well as these question.
Result: 1
let first lst = match lst with | a:: aa -> a;;
let rest lst = match lst with | [] -> [] | a:: aa -> aa;;
b. Use these types (i.e., start in an environment with these identifiers bound to these types) to give a type derivation for: let rec foldright f lst z = if lst = [] then z else (f (first lst) (foldright f (rest lst) z)) in foldright (+) [2;3;4] 0
i) a∨b∨c* ii) ((aba∨bab)c(aa∨bb))* iii) (ab)(c∨)(ba)
S → A a B | B a A A → b | c B → a | b Give an example of a string for which this grammar has two different parse trees, and give their parse trees.
true = λ a b. a false = λ a b. b if = λ c t e.c t e
Define the following functions as lambda terms:
a. and: b. or: c. not: d. eq:
a. Assuming Call by Name (Lazy Evaluation) b. Assuming Call by Value (Eager Evaluation) c. To full αβ-normal form.