title: assoc-equivalent procedure not functioning properly
body: <p>I am attempting to write a procedure similar to Scheme's assoc. The only difference between the two, is that I want my procedure only to return the value related to the key given, where as assoc gives the entire pair (key . value). Here is my procedure:</p>
  
  <pre><code>(define alist '((a . 1) (b . 2) (c . 3)))
  
  (define (search-list key list)
    (cond ((null? key) #f)
          ((eq? (caar list) key) (cdar list))
          ((null? (cdr list)) #f)
          (else search-list key (cdr list))))
  </code></pre>
  
  <p>I seem to be on the right track -- (search-list 'a alist) returns 1. However, when testing with (search-list 'b alist), this is my output: ((b . 2) (c . 3))</p>
  
  <p>I cannot understand why my procedure does not function as I intend it to. I would be very happy if you could point out the error in my procedure. Thanks in advance.</p>