Suggested Homework #1

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 : int = 2

- let x = 2 + 3 - 4.0 ;;

...

- let x = 2 + 3 ;;

...

- let x = "a" ;;

...

- let x = (x,3) ;;

...

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

...

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

...

- let z = if (x = y) then (snd x) else (snd y) ;;

...

- type myrecord = {f1 : int; f2 : string ; f3 : int} ;;

- let a = {f1 = x; f2 = (fst y); f3 = z} ;;

...

- let b = z::(snd y)::[] ;;

...

- let c = (x;y;z) ;;

...

- let c = (x,y,z) ;;

...

- let m = if (snd x) = (snd y) then b else [] ;;

...

- let n = if (1 > 2) then ["a";"b"] else [] ;;

...

- let o = if (m = n) then 2 else 3 ;;

...