Suggested Homework #2 (for Quiz #2 on 01/24/07)

Problem 1: Suppose that the following list of bindings was entered into the OCaml interpreter in the sequence shown. For each binding, write down :
(a) If the expression is accepted, the value bound ("fn" for functions) and its type,
(b) If the expression is rejected due to a type error, "type error",
(c) If the expression is rejected due to an unbound variable, the name of the variable that is not bound. Recall that if a type error occurs, then the variable binding does not happen. Check your answers by entering this sequence into the interpreter.
- let a =
    let x = 20 in
    let y = 
      let x = 5 in
	x + x 
    in
      x + y
    ;;

- let b = 
    let x = "ab" in
    let y = (let x = "cd" in x) ^ x in
      x ^ y
    ;;

- let c = 
    let x = 22 in
      x::y
    ;;














Problem 2: In each part below you are required to complete the implementation of a function by filling in the appropriate expressions in the blanks (parts marked ... ).