]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex2_66.clj
Solution to 4.44. A bit too verbose. Can be improved by better
[sicp.git] / src / sicp / ex2_66.clj
1 (ns sicp.ex2_66)
2
3 (defn lookup [given-key set-of-records]
4   (if (empty? set-of-records)
5     false
6     (let [record (entry set-of-records)]
7       (cond (= given-key (get-key record)) record
8             (< given-key (get-key record)) (lookup given-key (left-branch set-of-records))
9             (> given-key (get-key record)) (lookup given-key (right-branch set-of-records))))))