(* ** Course: Concepts of Programming Languages (BU CAS CS 320) ** Semester: Summer I, 2010 ** Instructor: Hongwei Xi (hwxi AT cs DOT bu DOT edu) *) // // Assignment Four (Due: Wednesday, June 16, 2010) // // Total points: 110 points // // Assgn4Ex1: 20 points // Assgn4Ex2: 30 points // Assgn4Ex3: 30 points // Assgn4Ex4: 30 points // (* ****** ****** *) // // // Assgn4Ex1: 20 points // // (* // // The following function is so-called MacCarthy's 91-function: // // f91(x) = f91 (f91 (x+11)) if x <= 100; // f91(x) = x - 10 if x > 100. // // Please give (1) an implementation of [f91] in direct-style and // (2) another one in continyuation-pass style. // // Note that 5 points are given for part (1) and 15 points for part (2) *) (* ****** ****** *) // // // Assgn4Ex2: 30 points // // datatype ltree (a:t@ype) = | ltree_nil (a) of () | ltree_cons (a) of (a, ref int(*size*), ref (ltree a), ref (ltree a)) // end of [ltree] // Please implement in-place left (BST) rotation fun{a:t@ype} ltree_rotate_l (t: ltree a): ltree a // Please implement in-place right (BST) rotation fun{a:t@ype} ltree_rotate_r (t: ltree a): ltree a // Please implement a function that changes the root of a given BST to // a randomly choosen node inside the tree while maintaining the BST status // of the tree fun{a:t@ype} ltree_random_root (t: ltree a): ltree a (* ****** ****** *) // // Assgn4Ex3: 30 points // Implement a procedure that takes two matrices and returns their // product. Note that two matrices can be multiplied only if they are of // dimensions $p\times q$ and $q \times r$ for some natural numbers $p,q,r$. // typedef matrx = list0 (list0 double) fun mul_matrx_matrx (A: matrx, B: matrx): matrx (* ****** ****** *) // // Assgn4Ex4: 30 points // Please implement a program in cairo for drawing the picture titled // "The wave of an earthquake" on the following page: // http://www.ritsumei.ac.jp/~akitaoka/wave-e.html // (* ****** ****** *) (* end of [assignment4.sats] *)