From d3f263959cba4c54a4e785ee0e34bc520d7d37c0 Mon Sep 17 00:00:00 2001 From: Ramakrishnan Muthukrishnan Date: Sun, 12 Sep 2010 23:41:08 +0530 Subject: [PATCH] adding the key lookup procedure --- src/sicp/ch2_3.clj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sicp/ch2_3.clj b/src/sicp/ch2_3.clj index a69973c..55ef8ad 100644 --- a/src/sicp/ch2_3.clj +++ b/src/sicp/ch2_3.clj @@ -136,3 +136,9 @@ (left-branch set) (adjoin-set x (right-branch set))))) + +;;; key lookup +(defn lookup [given-key set-of-records] + (cond (empty? set-of-records) false + (equal? given-key (key (first set-of-records))) (first set-of-records) + :else (lookup given-key (rest set-of-records)))) \ No newline at end of file -- 2.45.2