hw4 - Suggested Homework #3 Suggested Homework #4 (for Quiz...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Suggested Homework #3 Suggested Homework #4 (for Quiz #4 on 10/29/06) 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 ("fun" 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 foo (f,g) = fun x -> (f x,g x);; - let a = (foo (fun x -> x*x, fun x -> [x])) 4;; - let b = (foo (fun x -> ~x, fun x -> 0::x)) (4,[4]);; - let bar (f,a) = fun b -> f (a,b);; - let sum (a,b) = a+b;; - let c = (bar (sum,1));; - let d = c 2;; - let f = (bar (bar,bar)) sum;; - let g = f 4;; - let h = g 4;; - let i = h 4;; - let j = i 4;; Problem 2: In each part below you are required to complete the
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

hw4 - Suggested Homework #3 Suggested Homework #4 (for Quiz...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online