From: ·············@gmail.com
Subject: Lisp Question
Date: 
Message-ID: <1184809983.397550.151260@z28g2000prd.googlegroups.com>
Hi everyone,

I'm a new Lisp learner. I'm doing the DNA problem. The program is
supposed to count the bases A, T, G, and C in either a single dna
(represented by a list) or a complementary dna (represented by a
table). My program counts the thing right, but the variable result get
accumulated on subsequent call of the functions. I really don't
understand why. Could you shed some light?

Thanks.

(defun count-bases (strand)
  (let ((result '((a 0) (t 0) ( g 0) (c 0))))
    (dolist (base strand result)
      (cond ((atom base)(incf (second (assoc base result))))
            (t (incf (second (assoc (first base) result)))
               (incf (second (assoc (second base) result))))))))