Problems 2                             

Algebraic Types and Type Inference

1.      Define the function delete for sized binary search trees.

2.  Work out the type of each of the following function definitions, and give the  type declaration. You may assume that all the numbers have type Int. For example, given the definition

      f x = x+1

you would write the type declaration

            f :: Int -> Int

(Don't worry about type classes or overloading, but you should note that if you type these definitions into Hugs you will  get more general types with type class constraints.)

         i.            f1 x = x*5       

       ii.            f2 x y = (x, y, x)           

      iii.            f3 x y = (x+3, 'a' : y)    

     iv.            f4 a [ ] = a       

     f4 a (x:xs) = x*a : f4 a xs           

       v.            f5 x y z = (y,x) : z         

     vi.            f6 g a xs = map (g a) xs