6.001 Recitation #7 – Feb 26, 2003

 

RI: Konrad Tollmar

 

Program methodology

The MIT Scheme debugger
Catch-up

1. Prog practice

  1. Layout
  2. Documenting
  3. Debug
  4. Test case
  5. Types (number?, string?, Boolean?, List?, Pair? )

 

2. Errors

  1. Common Sources of (Scheme) Errors
  2. Scheme Error Messages
  3. MIT Scheme Debugging Tools
  4. Debugging Strategy

 

 

3. Let

 

Use let to write a procedure that compute

a = 1 + xy; b = 1 - y; f(x,y) = a2x + by + ab

 

4. Eval some list procedures.

x => (())

y => (1 2 3)

z => (1 (2 3) ((4)))

w => (1 2 3 4 5)

 

 

(map (lambda (x) (cons x nil)) y)

 

 

(map inc w)

 

 

(filter odd? w)

 

 

(map inc (filter odd? w))

 

 

(filter odd? (map inc w))

 

 

(accumulate + 0 (map inc (filter odd? w)))

 

 

 


5. What are the types of these procedures?

     1. length           

     2. list-ref       

     3. map                                     

     4. filter                                   5. accumulate

6. More higher-order procedures.

Write a function comp that takes two arguments a and b and returns a function, that when called with #t returns a and when called with #f returns b.