2015/10/27

SICP 問題 2.66

(define (lookup-tree given-key set-of-records)
  (cond (let ((key-record (key (car set-of-records))))
          ((null? set-of-records) false)
          ((= given-key key-record)
           (car set-of-records))
          ((< given-key key-record)
           (lookup-tree given-key (left-branch set-of-records)))
          ((< key-record given-key)
           (lookup-tree given-key (right-branch set-of-records))))))

© 2022 wat-aro