MATH 2220 Midterm: MATH 2220 Cornell Exam 2Solutions

74 views7 pages
31 Jan 2019
Department
Course
Professor

Document Summary

12 oct 2006: types, polymorphism [14 pts] (parts a b) That is, odd elements have some type "a, and even elements have some type "b. Answer: datatype ("a,"b) list = nil | cons of "a * ("b,"a) list: pattern matching [18 pts] (parts a b) (a) [8 pts] the following datatype describes syntax trees for arithmetic expressions: Answer: fun trans(e: expr): expr = case e of. | times(plus(e1,e2), e3) => plus(times(trans e1, trans e3), If list b is too short, excess elements are appended. For example: zip([1, 2, 3, 4], [11, 12, 13]) = [1, 11, 12, 2, 13, 3, 4] Answer: fun zip(a: int list, b: int list): int list = case (a, b) of (x::tx, y::y"::ty) => x::y::y"::zip(tx, ty) | ([], _) => b: using fold functions [20 pts] (parts a c) Absolute frequency distributions are obtained by dividing a data set into several classes and then counting the number of elements in each class.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related textbook solutions

Related Documents

Related Questions