sicp-ex-2.66



<< Previous exercise (2.65) | Index | Next exercise (2.67) >>


meteorgan

The solution is similar to element-of-set?

 (define (lookup given-key set-of-records) 
   (cond ((null? set-of-records) #f) 
         ((= given-key (key (entry set-of-records))) 
          (entry set-of-records)) 
         ((< given-key (key (entry set-of-records))) 
          (lookup given-key (left-branch set-of-records))) 
         (else (lookup given-key (right-branch set-of-records)))))