This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: function getFirsts which given a list of pairs, returns a list of the 1 st members of each pair as a list (in original or reverse order). Partial credit given for solutions which do not use map/fold. Example: getFirsts [(1,2);(3,4);(3,5)] = [1;3;3] OR [3;3;1] getFirsts [(“a”,”x”);(“b”,”y”);(“c”,”z”)] = [“a”;”b”;”c”] OR [“c”;”b”;”a”] 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. b. (4 pts) Is the grammar ambiguous? Show proof if possible. 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
 Fall '08
 staff
 Functional Programming, pts, following OCaml expression

Click to edit the document details