STAT 102 Midterm: STAT 102 UPenn Midterm2Fall 2000

22 views13 pages
31 Jan 2019
School
Department
Course
Professor

Document Summary

Circle the nal result of simplifying the following ocaml expressions, or in nite loop if there is no nal answer. Note: the de nition of the transform function appears on page 11. Also recall that the @ operator appends lists together: let rec f (x :int) (m : int list) : bool = begin match m with. | [] :: u -> 0 :: h u. | (x :: t) :: u -> 1 :: h (t :: u) end in h [[1];[];[1;2]: [1;0;0;1;1;0, [1;1;2, [1;0;1;1, [[1];[];[1;1], in nite loop. For each ocaml value below, ll in the blank where the type annotation could go or write ill typed if there is a type error on that line. Your answer should be the most speci c type possible, i. e. int list instead of "a list. Some of these expressions refer to values speci ed by the set interface from homework 3.