]> git.rkrishnan.org Git - sicp.git/commitdiff
adding the key lookup procedure
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Sun, 12 Sep 2010 18:11:08 +0000 (23:41 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Sun, 12 Sep 2010 18:11:08 +0000 (23:41 +0530)
src/sicp/ch2_3.clj

index a69973c95cfd54d55745294c714f8d1db412d4cf..55ef8adbb5c3631bcff8497c5cba84bf278ac2c1 100644 (file)
                                      (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