This preview shows page 1. Sign up to view the full content.
Unformatted text preview: let getFirsts lst = map (fun a -> match a with (h,t) -> h) lst OR let getFirsts lst = map (fun (h,t) -> h) lst OR let getFirsts lst = fold (fun a y -> match y with (h,t) -> h::a) lst OR let getFirsts lst = fold (fun a (h,t) -> h::a) lst etc… 3. (6 pts) Context free grammars Consider the following grammar: S & aSaS | ± (* epsilon *) a. (2 pts) Describe the set of strings generated by the grammar. Strings of even numbers of a’s. I.e., (aa)* b. (4 pts) Is the grammar ambiguous? Show proof if possible. Grammar is ambiguous since there are 2 leftmost derivations for “aaaa”. S ± aSaS ± aaS ²± aaaSaS ± aaaaS ± aaaa S ± aSaS ± aaSaSaS ± aaaSaS ± aaaaS ± aaaa let rec map f l = match l with -> | (h::t) -> (f h)::(map f t) let rec fold f a l = match l with -> a | (h::t) -> fold f (f a h) t...
View Full Document
This note was uploaded on 01/13/2012 for the course CMSC 330 taught by Professor Staff during the Fall '08 term at Maryland.
- Fall '08