title: Common Lisp: unable to get the uncompress function in Paul Graham's book working
body: <p>Lisp newbie here.</p>
  
  <p>I am reading Paul Graham's book, ANSI Common Lisp.</p>
  
  <p>On page 38 is an <code>uncompress</code> function. It takes a list of pairs, where the first item in the pair is a number to indicate how many of the second item there should be. For example, uncompressing this:</p>
  
  <pre><code>((3 a) (2 b) c)
  </code></pre>
  
  <p>should produce this:</p>
  
  <pre><code>(A A A B B C)
  </code></pre>
  
  <p>I typed the <code>uncompress</code> function into a Lisp interpreter (GCL-2.6.2-ANSI) and then tested it like this:</p>
  
  <pre><code>(uncompress '((3 A) B (2 C) (5 D)))
  </code></pre>
  
  <p>That produced this error message:</p>
  
  <pre><code>Error in IF [or a callee]: Too many arguments.
  
  Fast links are on: do (use-fast-links nil) for debugging
  Broken at IF.  Type :H for Help.
   1 (Abort) Return to top level.
  </code></pre>
  
  <p>Below is the <code>uncompress</code> function. I think that I faithfully typed what was written in the book. I have tested each piece and each piece seems to work correctly. Truthfully, I'm stuck. I don't know what's causing the error. I'd appreciate your help.</p>
  
  <pre><code>(defun uncompress (lst)
     (if (null lst)
         nil
         (let (elt (car lst))
              (rest (uncompress (cdr lst))))
          (if (consp elt)
              (append (apply #'list-of elt)
                      rest)
              (cons elt rest))))
  
  (defun list-of (n elt)
     (if (zerop n)
         nil
         (cons elt (list-of (- n 1) elt))))
  </code></pre>