CSCI 3675
Fall 2000
Exercise Set 2

Due: Wednesday, September 20.

  1. 6.1. Using equations (6.5.1), show an inside-out evaluation of expression pow(2,5). [In the old notes, that will be in Chapter 5, the definition of pow.]

  2. 6.3. Write an equational definition of digitsum, where digitsum(n) is the sum of the digits in decimal number n. For example, digitsum(554) = 5 + 5 + 4 = 14.

  3. 7.2. Show an inside-out evaluation of expression take(2, [4,3,2]).

  4. 7.5. Write an equational definition of function ziplist, where ziplist([a,b,c,d], [u,v,w,x]) = [[a,u], [b,v], [c,w], [d,x]]. In general, ziplist takes a list of pairs and produces a pair of lists. (The analogy is with the action of a zipper.) Assume that the two lists have the same length. Do not worry about what happens if they have different lengths.

  5. 7.7. Write an equational definition of function positives(x) that produces a list of the positive members of list x. For example, positives([2,-6,-1,4,0]) = [2,4].