Spring 2001, CSE 428: Quiz 9.1 - 29 March 2001


Please write your Name and Student ID,at the top of the page.
By default, this quiz will be returned in Section 2 (morning section).
  1. [Pts 4]  Consider the following definition of the function "member"
       fun memb(x, []) = false
         | memb(x, y::L) = if x = y then true else memb(x,L);
    
    For each of the following expressions, say what is the result (true, false, or error). Remember that the two arguments of "=" must have the same type, and that it must be an equality type.

  2. [Pts 2]  Consider the following datatype representing binary trees with integer labels, and the definition of a function f on that datatype (remember that @ is the pre-defined append function):
       datatype tree = Leaf of int | Node of (tree * int * tree);
     
       fun f (Leaf n) = [n]
         | f (Node(t1,n,t2)) = (f t1) @ (n::(f t2));
    
    Say what is the semantics of f (only one answer, please)

  3. [Pts 2]  Consider the following function map:
        fun map(f, []) = []
          | map(f, x::L) = (f x) :: (map(f,L));
    
    Say what is the result of the following expression (only one answer, please)
     
       map( fn (x,y) => if x < y then y else x , [(2,1),(3,4),(5,6)] )
    

  4. [Pts 2]  An anonymous function is: (only one answer, please)