

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)) in foldright (+) [2;3;4] 0
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:
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.
a. Assuming Call by Name (Lazy Evaluation) b. Assuming Call by Value (Eager Evaluation)
type comm = ... | If of (bool_exp * comm * comm) | ... type bool_exp = True_exp | False_exp | ...