title: Common lisp error: "should be lambda expression"
body: <p>I just started learning Common Lisp a few days ago, and I'm trying to build a function that inserts a number into a tree. I'm getting an error,</p>
  
  <blockquote>
    <p>*** - SYSTEM::%EXPAND-FORM: (CONS NIL LST) should be a lambda expression</p>
  </blockquote>
  
  <p>From googling around, it seems like this happens when you have too many sets of parenthesis, but after looking at this for an hour or so and changing things around, I can't figure out where I could be doing this.</p>
  
  <p>This is the code where it's happening:</p>
  
  <pre><code>(defun insert (lst probe)
      (cond ((null lst) (cons probe lst))
          ((equal (length lst) 1)
              (if (&lt;= probe (first lst))
                  (cons probe lst)
                  (append lst (list probe))))
          ((equal (length lst) 2)
              ((cons nil lst) (append lst nil) (insertat nil lst 3)
                  (cond ((&lt;= probe (second lst)) (insert (first lst) probe))
                       ((&gt; probe (fourth lst)) (insert (fifth lst) probe))
                       (t (insert (third lst) probe)))))))
  </code></pre>
  
  <p>I'm pretty sure it's occurring after the ((equal (length lst) 2), where the idea is to insert an empty list into the existing list, then append an empty list onto the end, then insert an empty list into the middle.</p>