title: "set! not an identifier" in Scheme
body: <p>I am trying to modify the cdr of the car of an element of a list using set!, but I am getting an error: "set! not an identifier". Can anyone explain to me why this is happening? I am starting to work with objects by the way.</p>
  
  <pre><code>#lang racket
  (define (multiset)
    (let ((main-list '()))
      (define (empty) 
        (eq? main-list '()))
      (define (insert x)
         (cond ((empty) 
                     (set! main-list (cons (cons x 1) main-list)))
               ((= (car (car main-list)) x) 
                     (begin (set! (cdr (car main-list)) 
                                  (+ 1 (cdr (car main-list))))))
               (else (cdr main-list))))
  </code></pre>
  
  <p>A multiset is represented as a list of pairs. For example, if I had a list '(1 1 1 2 2 2), the multiset representation would be '((1.3)(2.3))</p>