

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!


let first lst = match lst with | a:: aa -> a;;
let rest lst = match lst with | [] -> [] | a:: aa -> aa;;
Use these types to derive the types for:
b. let rec foldright f lst z = if lst == [] then z else (f (first lst) (foldright f (rest lst) z)) c. foldright (+) [2;3;4] 0
a. Assuming Call by Name (Eager Evaluation) b. Assuming Call by Value (Lazy Evaluation)
true = λ a b. a false = λ a b. b if = λ c t e.c t e
Define functions which:
a. and b. or: c. not: d. eq:
let a = 3 in let p x = x * a in let a = 5 in a + (p 7);;
a. assuming static scope (a.k.a. lexical scope): b. assuming dynamic scope:
S → A a B | B a A A → b | c B → a | b
a. Give an example of a string for which this grammar has two different parse trees, and give their parse trees. b. Give the two leftmost derivations corresponding to those parse trees.