MATH 114 Midterm: MATH 114 UPenn 114Fall 05web Exam

15 views12 pages
31 Jan 2019
School
Department
Course
Professor

Document Summary

My signature below certi es that i have complied with the university of pennsylvania"s code of. Answer: r = b. let rec f (l : "a list) : ("a list * "a list) = begin match l with. | u::v::w -> let (y,z) : ("a list * "a list) = f w in (u::y, v::z) end let r : ("a list * "a list) = f [1;2;3;4;5] Answer: r = c. let rec f (x : ("a -> "b) list) (y : "a) : "b list = begin match x with. | h::t -> h y :: f t y. | _ -> [] end let r : int list = f [(fun x -> - x); (fun x -> x * (x + 1))] 6. For each ocaml value or function de nition below, ll in the blank where the type annotation could go or write ill typed if there is a type error.