Suggested Homework #1 (for Quiz #1 on 01/17/07)

Suppose that the following list of bindings was entered into the OCaml interpreter. For each binding, the interpreter responds with either: (a) the name of the variable, its value, and its type, as shown for the first binding in italics , or (b) a type error.
Fill in the blanks ("...") with how the interpreter would respond if each of the bindings was entered in the sequence shown below. Recall that if a type error occurs, then the variable binding does not happen. Note that you could just enter this sequence into the interpreter and see what happens, but this is a luxury you will not have during the quiz.

- let x = 2 ;;

val x = 2 : int;

- let x = 2 + 3 - 4.0 ;;

...

- let x = 2 + 3 ;;

...

- let x = "a" ;;

...

- let x = (x,3) ;;

...

- let (x,y) = x ;;

...

- let y = (x^"b" , y^"c") ;;

...

- let y = (x , y+3) ;;

...

- let a = [1;2] ;;

...

- let a = (0::a)@[1;2] ;;

...

- let i::t = a ;;

...

- 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
    ;;